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 /* Public methods */ 1344 GLSLContantImmutablityTest(deqp::Context &context); 1345 ~GLSLContantImmutablityTest()1346 virtual ~GLSLContantImmutablityTest() 1347 { 1348 } 1349 1350 protected: 1351 /* Methods to be implemented by child class */ 1352 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 1353 1354 virtual std::string getTestCaseName(glw::GLuint test_case_index); 1355 virtual glw::GLuint getTestCaseNumber(); 1356 virtual bool isComputeRelevant(glw::GLuint test_case_index); 1357 virtual void testInit(); 1358 1359 private: 1360 /* Private enums */ 1361 enum CONSTANTS 1362 { 1363 GL_ARB_ENHANCED_LAYOUTS, 1364 GL_MAX_XFB, 1365 GL_MAX_XFB_INT_COMP, 1366 1367 /* */ 1368 CONSTANTS_MAX, 1369 }; 1370 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 }; 1384 1385 /** Implementation of test GLSLConstantIntegralExpression. Description follows: 1386 * 1387 * Check that following symbols can be used as integral constant expressions: 1388 * 1389 * GL_ARB_enhanced_layouts, 1390 * gl_MaxTransformFeedbackBuffers, 1391 * gl_MaxTransformFeedbackInterleavedComponents. 1392 * 1393 * Test implement Texture algorithm. Test following code snippet: 1394 * 1395 * uniform uint goku [GL_ARB_enhanced_layouts / GOKU_DIV]; 1396 * uniform uint gohan[gl_MaxTransformFeedbackBuffers / GOHAN_DIV]; 1397 * uniform uint goten[gl_MaxTransformFeedbackInterleavedComponents / 1398 * GOTEN_DIV]; 1399 * 1400 * for (i = 0; i < goku.length; ++i) 1401 * goku_sum += goku[i]; 1402 * 1403 * for (i = 0; i < gohan.length; ++i) 1404 * gohan_sum += gohan[i]; 1405 * 1406 * for (i = 0; i < goten.length; ++i) 1407 * goten_sum += goten[i]; 1408 * 1409 * if ( (expected_goku_sum == goku_sum) && 1410 * (expected_gohan_sum == gohan_sum) && 1411 * (expected_goten_sum == goten_sum) ) 1412 * result = 1; 1413 * else 1414 * result = 0; 1415 * 1416 * Select DIV values so as array lengths are below 16. 1417 **/ 1418 class GLSLConstantIntegralExpressionTest : public TextureTestBase 1419 { 1420 public: 1421 /* Public methods */ 1422 GLSLConstantIntegralExpressionTest(deqp::Context &context); 1423 ~GLSLConstantIntegralExpressionTest()1424 virtual ~GLSLConstantIntegralExpressionTest() 1425 { 1426 } 1427 1428 protected: 1429 /* Protected methods */ 1430 virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 1431 Utils::VaryingPassthrough &varying_passthrough); 1432 1433 virtual std::string getVerificationSnippet(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 1434 Utils::Shader::STAGES stage); 1435 1436 virtual void prepareUniforms(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 1437 Utils::Program &program, Utils::Buffer &cs_buffer); 1438 1439 virtual void prepareUniforms(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 1440 Utils::Program &program, Utils::Buffer &fs_buffer, Utils::Buffer &gs_buffer, 1441 Utils::Buffer &tcs_buffer, Utils::Buffer &tes_buffer, Utils::Buffer &vs_buffer); 1442 1443 private: 1444 glw::GLint m_gohan_length; 1445 glw::GLint m_goten_length; 1446 }; 1447 1448 /** Implementation of test UniformBlockMemberOffsetAndAlign. Description follows: 1449 * 1450 * Test verifies that: 1451 * - offset and align qualifiers are respected for uniform block members, 1452 * - align qualifier is ignored if value is too small, 1453 * - align qualifier accepts values bigger than size of base type, 1454 * - manual and automatic offsets and alignments can be mixed. 1455 * 1456 * This test implement Texture algorithm. Test following code snippet: 1457 * 1458 * const int basic_size = sizeof(basic_type_of(type)); 1459 * const int type_size = sizeof(type); 1460 * const int type_align = roundUpToPowerOf2(type_size); 1461 * 1462 * layout (std140, offset = 0) uniform Block { 1463 * layout(align = 8 * basic_size) type at_first_offset; 1464 * layout(offset = type_size, align = basic_size / 2) 1465 * type at_second_offset; 1466 * layout(align = 2 * type_align) type at_third_offset; 1467 * layout(offset = 3 * type_align + type_size) 1468 * type at_fourth_offset; 1469 * type at_fifth_offset; 1470 * type at_sixth_offset[2]; 1471 * layout(align = 8 * basic_size) type at_eight_offset; 1472 * }; 1473 * 1474 * if ( (at_first_offset == at_eight_offset ) && 1475 * (at_second_offset == at_sixth_offset[1]) && 1476 * (at_third_offset == at_sixth_offset[0]) && 1477 * (at_fourth_offset == at_fifth_offset ) ) 1478 * result = 1; 1479 * else 1480 * result = 0; 1481 * 1482 * Additionally inspect program to verify that all block members: 1483 * - are reported, 1484 * - have correct offsets. 1485 * 1486 * Test should be executed for all types. 1487 **/ 1488 class UniformBlockMemberOffsetAndAlignTest : public TextureTestBase 1489 { 1490 public: 1491 /* Public methods */ 1492 UniformBlockMemberOffsetAndAlignTest(deqp::Context &context); 1493 ~UniformBlockMemberOffsetAndAlignTest()1494 virtual ~UniformBlockMemberOffsetAndAlignTest() 1495 { 1496 } 1497 1498 protected: 1499 /* Protected methods */ 1500 virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 1501 Utils::VaryingPassthrough &varying_passthrough); 1502 1503 virtual std::string getTestCaseName(glw::GLuint test_case_index); 1504 virtual glw::GLuint getTestCaseNumber(); 1505 1506 virtual std::string getVerificationSnippet(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 1507 Utils::Shader::STAGES stage); 1508 1509 private: 1510 std::vector<glw::GLubyte> m_data; 1511 }; 1512 1513 /** Implementation of test UniformBlockLayoutQualifierConflict. Description follows: 1514 * 1515 * Test verifies that offset and align can only be used on members of blocks 1516 * declared as std140. 1517 * 1518 * Test following code snippet with all shader stages: 1519 * 1520 * layout(QUALIFIER) uniform Block { 1521 * layout(offset = 16) vec4 b; 1522 * layout(align = 48) vec4 a; 1523 * }; 1524 * 1525 * Test following block qualifiers and all types: 1526 * 1527 * default - meaning not declared by shader 1528 * std140, 1529 * shared, 1530 * packed. 1531 * 1532 * Qualifier std430 is not allowed for uniform blocks. 1533 * 1534 * Test expect that only case using std140 will compile and link successfully, 1535 * while the rest will fail to compile or link. 1536 **/ 1537 class UniformBlockLayoutQualifierConflictTest : public NegativeTestBase 1538 { 1539 public: 1540 /* Public methods */ 1541 UniformBlockLayoutQualifierConflictTest(deqp::Context &context); 1542 ~UniformBlockLayoutQualifierConflictTest()1543 virtual ~UniformBlockLayoutQualifierConflictTest() 1544 { 1545 } 1546 1547 protected: 1548 /* Methods to be implemented by child class */ 1549 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 1550 1551 virtual std::string getTestCaseName(glw::GLuint test_case_index); 1552 virtual glw::GLuint getTestCaseNumber(); 1553 1554 virtual bool isComputeRelevant(glw::GLuint test_case_index); 1555 virtual bool isFailureExpected(glw::GLuint test_case_index); 1556 virtual void testInit(); 1557 1558 private: 1559 /* Private enums */ 1560 enum QUALIFIERS 1561 { 1562 DEFAULT, 1563 STD140, 1564 SHARED, 1565 PACKED, 1566 1567 /* */ 1568 QUALIFIERS_MAX, 1569 }; 1570 1571 /* Private types */ 1572 struct testCase 1573 { 1574 QUALIFIERS m_qualifier; 1575 Utils::Shader::STAGES m_stage; 1576 }; 1577 1578 /* Private methods */ 1579 const glw::GLchar *getQualifierName(QUALIFIERS qualifier); 1580 1581 /* Private fields */ 1582 std::vector<testCase> m_test_cases; 1583 }; 1584 1585 /** Implementation of test UniformBlockMemberInvalidOffsetAlignment. Description follows: 1586 * 1587 * Test verifies that offset alignment rules are enforced. 1588 * 1589 * Declare uniform block, which contains following member declaration: 1590 * 1591 * layout(offset = X) type block_member 1592 * 1593 * Shader compilation is expected to fail for any X that is not a multiple of 1594 * the base alignment of type. 1595 * Test all offsets covering locations first and one before last: 1596 * 1597 * <0, sizeof(type)> 1598 * <MAX_UNIFORM_BLOCK_SIZE - 2 * sizeof(type), 1599 * MAX_UNIFORM_BLOCK_SIZE - sizeof(type)> 1600 * 1601 * Test all shader stages. Test all types. Each case should be tested 1602 * separately. 1603 **/ 1604 class UniformBlockMemberInvalidOffsetAlignmentTest : public NegativeTestBase 1605 { 1606 public: 1607 /* Public methods */ 1608 UniformBlockMemberInvalidOffsetAlignmentTest(deqp::Context &context); 1609 1610 UniformBlockMemberInvalidOffsetAlignmentTest(deqp::Context &context, const glw::GLchar *name, 1611 const glw::GLchar *description); 1612 ~UniformBlockMemberInvalidOffsetAlignmentTest()1613 virtual ~UniformBlockMemberInvalidOffsetAlignmentTest() 1614 { 1615 } 1616 1617 protected: 1618 /* Methods to be implemented by child class */ 1619 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 1620 1621 virtual std::string getTestCaseName(glw::GLuint test_case_index); 1622 virtual glw::GLuint getTestCaseNumber(); 1623 virtual glw::GLint getMaxBlockSize(); 1624 virtual bool isComputeRelevant(glw::GLuint test_case_index); 1625 virtual bool isFailureExpected(glw::GLuint test_case_index); 1626 virtual bool isStageSupported(Utils::Shader::STAGES stage); 1627 virtual void testInit(); 1628 1629 protected: 1630 /* Protected types */ 1631 struct testCase 1632 { 1633 glw::GLuint m_offset; 1634 bool m_should_fail; 1635 Utils::Shader::STAGES m_stage; 1636 Utils::Type m_type; 1637 }; 1638 1639 /* Protected fields */ 1640 std::vector<testCase> m_test_cases; 1641 }; 1642 1643 /** Implementation of test UniformBlockMemberOverlappingOffsets. Description follows: 1644 * 1645 * Test verifies that block members cannot overlap. 1646 * 1647 * Use following code snippet: 1648 * 1649 * layout (std140) uniform Block { 1650 * layout (offset = b_offset) b_type b; 1651 * layout (offset = a_offset) a_type a; 1652 * }; 1653 * 1654 * It is expected that overlapping members will cause compilation failure. 1655 * 1656 * There are three cases to test: 1657 * 1658 * - when member is declared with the same offset as already declared 1659 * member, 1660 * - when member is declared with offset that lay in the middle of already 1661 * declared member, 1662 * - when member is declared with offset just before already declared 1663 * member and there is not enough space. 1664 * 1665 * Test all shader stages. Test all types. Test cases separately. 1666 * 1667 * Note that not all type combinations let to test all three cases, e.g. 1668 * vec4 and float. 1669 **/ 1670 class UniformBlockMemberOverlappingOffsetsTest : public NegativeTestBase 1671 { 1672 public: 1673 /* Public methods */ 1674 UniformBlockMemberOverlappingOffsetsTest(deqp::Context &context); 1675 1676 UniformBlockMemberOverlappingOffsetsTest(deqp::Context &context, const glw::GLchar *name, 1677 const glw::GLchar *description); 1678 ~UniformBlockMemberOverlappingOffsetsTest()1679 virtual ~UniformBlockMemberOverlappingOffsetsTest() 1680 { 1681 } 1682 1683 protected: 1684 /* Methods to be implemented by child class */ 1685 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 1686 1687 virtual std::string getTestCaseName(glw::GLuint test_case_index); 1688 virtual glw::GLuint getTestCaseNumber(); 1689 virtual bool isComputeRelevant(glw::GLuint test_case_index); 1690 virtual bool isStageSupported(Utils::Shader::STAGES stage); 1691 virtual void testInit(); 1692 1693 protected: 1694 /* Protected types */ 1695 struct testCase 1696 { 1697 glw::GLuint m_b_offset; 1698 Utils::Type m_b_type; 1699 glw::GLuint m_a_offset; 1700 Utils::Type m_a_type; 1701 Utils::Shader::STAGES m_stage; 1702 }; 1703 1704 /* Protected methods */ 1705 glw::GLuint gcd(glw::GLuint a, glw::GLuint b); 1706 glw::GLuint lcm(glw::GLuint a, glw::GLuint b); 1707 1708 /* Protected fields */ 1709 std::vector<testCase> m_test_cases; 1710 }; 1711 1712 /** Implementation of test UniformBlockMemberAlignNonPowerOf2. Description follows: 1713 * 1714 * Test verifies that align qualifier must use power of 2. 1715 * 1716 * Test following code snippet: 1717 * 1718 * layout (std140, offset = 8) uniform Block { 1719 * vec4 b; 1720 * layout (align = a_alignment) type a; 1721 * }; 1722 * 1723 * It is expected that compilation will fail whenever a_alignment is not 1724 * a power of 2. 1725 * 1726 * Test all alignment in range <0, sizeof(dmat4)>. Test all shader stages. 1727 * Test all types. 1728 **/ 1729 class UniformBlockMemberAlignNonPowerOf2Test : public NegativeTestBase 1730 { 1731 public: 1732 /* Public methods */ 1733 UniformBlockMemberAlignNonPowerOf2Test(deqp::Context &context); 1734 1735 UniformBlockMemberAlignNonPowerOf2Test(deqp::Context &context, const glw::GLchar *name, 1736 const glw::GLchar *description); 1737 ~UniformBlockMemberAlignNonPowerOf2Test()1738 virtual ~UniformBlockMemberAlignNonPowerOf2Test() 1739 { 1740 } 1741 1742 protected: 1743 /* Methods to be implemented by child class */ 1744 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 1745 1746 virtual std::string getTestCaseName(glw::GLuint test_case_index); 1747 virtual glw::GLuint getTestCaseNumber(); 1748 virtual bool isComputeRelevant(glw::GLuint test_case_index); 1749 virtual bool isFailureExpected(glw::GLuint test_case_index); 1750 virtual bool isStageSupported(Utils::Shader::STAGES stage); 1751 virtual void testInit(); 1752 1753 protected: 1754 /* Protected types */ 1755 struct testCase 1756 { 1757 glw::GLuint m_alignment; 1758 Utils::Type m_type; 1759 bool m_should_fail; 1760 Utils::Shader::STAGES m_stage; 1761 }; 1762 1763 /* Protected methods */ 1764 bool isPowerOf2(glw::GLuint val); 1765 1766 /* Protected fields */ 1767 std::vector<testCase> m_test_cases; 1768 }; 1769 1770 /** Implementation of test UniformBlockAlignment. Description follows: 1771 * 1772 * UniformBlockAlignment 1773 * 1774 * Test verifies that align qualifier is applied to block members as specified. 1775 * 1776 * This test implements Texture algorithm. Test following code snippet: 1777 * 1778 * struct Data { 1779 * vec4 vector; 1780 * float scalar; 1781 * }; 1782 * 1783 * layout (std140, offset = 8, align = 64) uniform Block { 1784 * vec4 first; 1785 * Data second; 1786 * Data third[2]; 1787 * vec4 fourth[3]; 1788 * layout (align = 16) vec4 fifth[2]; 1789 * Data sixth; 1790 * }; 1791 * 1792 * Verify that all uniforms have correct values. Additionally inspect program 1793 * to check that all offsets are as expected. 1794 **/ 1795 class UniformBlockAlignmentTest : public TextureTestBase 1796 { 1797 public: 1798 /* Public methods */ 1799 UniformBlockAlignmentTest(deqp::Context &context); 1800 ~UniformBlockAlignmentTest()1801 virtual ~UniformBlockAlignmentTest() 1802 { 1803 } 1804 1805 protected: 1806 /* Protected methods */ 1807 virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 1808 Utils::VaryingPassthrough &varying_passthrough); 1809 1810 private: 1811 std::vector<glw::GLubyte> m_data; 1812 }; 1813 1814 /** Implementation of test SSBMemberOffsetAndAlign. Description follows: 1815 * 1816 * Test verifies that: 1817 * - offset and align qualifiers are respected for shader storage block 1818 * members, 1819 * - align qualifier is ignored if value is too small, 1820 * - align qualifier accepts values bigger than size of base type, 1821 * - manual and automatic offsets and alignments can be mixed. 1822 * 1823 * Modify UniformBlockMemberOffsetAndAlign to test shader storage block instead 1824 * of uniform block. 1825 **/ 1826 class SSBMemberOffsetAndAlignTest : public TextureTestBase 1827 { 1828 public: 1829 /* Public methods */ 1830 SSBMemberOffsetAndAlignTest(deqp::Context &context); ~SSBMemberOffsetAndAlignTest()1831 virtual ~SSBMemberOffsetAndAlignTest() 1832 { 1833 } 1834 1835 protected: 1836 /* Protected methods */ 1837 virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 1838 Utils::VaryingPassthrough &varying_passthrough); 1839 1840 virtual std::string getTestCaseName(glw::GLuint test_case_index); 1841 virtual glw::GLuint getTestCaseNumber(); 1842 1843 virtual std::string getVerificationSnippet(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 1844 Utils::Shader::STAGES stage); 1845 1846 virtual bool isDrawRelevant(glw::GLuint test_case_index); 1847 1848 private: 1849 std::vector<glw::GLubyte> m_data; 1850 }; 1851 1852 /** Implementation of test SSBLayoutQualifierConflict. Description follows: 1853 * 1854 * Test verifies that offset and align can only be used on members of blocks 1855 * declared as std140 or std430. 1856 * 1857 * Modify UniformBlockMemberOffsetAndAlign to test shader storage block instead 1858 * of uniform block. 1859 * 1860 * Qualifier std430 is allowed for shader storage blocks, it should be included 1861 * in test. It is expected that std430 case will build successfully. 1862 **/ 1863 class SSBLayoutQualifierConflictTest : public NegativeTestBase 1864 { 1865 public: 1866 /* Public methods */ 1867 SSBLayoutQualifierConflictTest(deqp::Context &context); 1868 ~SSBLayoutQualifierConflictTest()1869 virtual ~SSBLayoutQualifierConflictTest() 1870 { 1871 } 1872 1873 protected: 1874 /* Methods to be implemented by child class */ 1875 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 1876 1877 virtual std::string getTestCaseName(glw::GLuint test_case_index); 1878 virtual glw::GLuint getTestCaseNumber(); 1879 virtual bool isComputeRelevant(glw::GLuint test_case_index); 1880 virtual bool isFailureExpected(glw::GLuint test_case_index); 1881 virtual void testInit(); 1882 1883 private: 1884 /* Private enums */ 1885 enum QUALIFIERS 1886 { 1887 DEFAULT, 1888 STD140, 1889 STD430, 1890 SHARED, 1891 PACKED, 1892 1893 /* */ 1894 QUALIFIERS_MAX, 1895 }; 1896 1897 /* Private types */ 1898 struct testCase 1899 { 1900 QUALIFIERS m_qualifier; 1901 Utils::Shader::STAGES m_stage; 1902 }; 1903 1904 /* Private methods */ 1905 const glw::GLchar *getQualifierName(QUALIFIERS qualifier); 1906 bool isStageSupported(Utils::Shader::STAGES stage); 1907 1908 /* Private fields */ 1909 std::vector<testCase> m_test_cases; 1910 }; 1911 1912 /** Implementation of test SSBMemberInvalidOffsetAlignment. Description follows: 1913 * 1914 * Test verifies that offset alignment rules are enforced. 1915 * 1916 * Modify UniformBlockMemberInvalidOffsetAlignment to test shader 1917 * storage block against MAX_SHADER_STORAGE_BLOCK_SIZE instead of 1918 * uniform block 1919 **/ 1920 class SSBMemberInvalidOffsetAlignmentTest : public UniformBlockMemberInvalidOffsetAlignmentTest 1921 { 1922 public: 1923 /* Public methods */ 1924 SSBMemberInvalidOffsetAlignmentTest(deqp::Context &context); 1925 ~SSBMemberInvalidOffsetAlignmentTest()1926 virtual ~SSBMemberInvalidOffsetAlignmentTest() 1927 { 1928 } 1929 1930 protected: 1931 /* Methods to be implemented by child class */ 1932 virtual glw::GLint getMaxBlockSize(); 1933 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 1934 1935 virtual bool isStageSupported(Utils::Shader::STAGES stage); 1936 }; 1937 1938 /** Implementation of test SSBMemberOverlappingOffsets. Description follows: 1939 * 1940 * Test verifies that block members cannot overlap. 1941 * 1942 * Modify UniformBlockMemberOverlappingOffsets to test shader storage block 1943 * instead of uniform block. 1944 **/ 1945 class SSBMemberOverlappingOffsetsTest : public UniformBlockMemberOverlappingOffsetsTest 1946 { 1947 public: 1948 /* Public methods */ 1949 SSBMemberOverlappingOffsetsTest(deqp::Context &context); ~SSBMemberOverlappingOffsetsTest()1950 virtual ~SSBMemberOverlappingOffsetsTest() 1951 { 1952 } 1953 1954 protected: 1955 /* Methods to be implemented by child class */ 1956 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 1957 1958 virtual bool isStageSupported(Utils::Shader::STAGES stage); 1959 }; 1960 1961 /** Implementation of test SSBMemberAlignNonPowerOf2. Description follows: 1962 * 1963 * Test verifies that align qualifier must use power of 2. 1964 * 1965 * Modify UniformBlockMemberAlignNonPowerOf2 to test shader storage block 1966 * instead of uniform block. 1967 **/ 1968 class SSBMemberAlignNonPowerOf2Test : public UniformBlockMemberAlignNonPowerOf2Test 1969 { 1970 public: 1971 /* Public methods */ 1972 SSBMemberAlignNonPowerOf2Test(deqp::Context &context); 1973 ~SSBMemberAlignNonPowerOf2Test()1974 virtual ~SSBMemberAlignNonPowerOf2Test() 1975 { 1976 } 1977 1978 protected: 1979 /* Methods to be implemented by child class */ 1980 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 1981 1982 virtual bool isStageSupported(Utils::Shader::STAGES stage); 1983 }; 1984 1985 /** Implementation of test SSBAlignment. Description follows: 1986 * 1987 * Test verifies that align qualifier is applied to block members as specified. 1988 * 1989 * Modify UniformBlockAlignment to test shader storage block instead 1990 * of uniform block. 1991 **/ 1992 class SSBAlignmentTest : public TextureTestBase 1993 { 1994 public: 1995 /* Public methods */ 1996 SSBAlignmentTest(deqp::Context &context); 1997 ~SSBAlignmentTest()1998 virtual ~SSBAlignmentTest() 1999 { 2000 } 2001 2002 protected: 2003 /* Protected methods */ 2004 virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 2005 Utils::VaryingPassthrough &varying_passthrough); 2006 2007 virtual bool isDrawRelevant(glw::GLuint test_case_index); 2008 2009 private: 2010 std::vector<glw::GLubyte> m_data; 2011 }; 2012 2013 /** Implementation of test VaryingLocations. Description follows: 2014 * 2015 * Test verifies that "varying" locations are assigned as declared in shader. 2016 * 2017 * This test implements Texture algorithm. Use separate shader objects instead 2018 * of monolithic program. Test following code snippet: 2019 * 2020 * layout(location = 0) in type input_at_first_location; 2021 * layout(location = last_input) in type input_at_last_location; 2022 * layout(location = 1) out type output_at_first_location; 2023 * layout(location = last_output) out type output_at_last_location; 2024 * 2025 * output_at_first_location = input_at_first_location; 2026 * output_at_last_location = input_at_last_location; 2027 * 2028 * if ( (EXPECTED_VALUE == input_at_first_location) && 2029 * (EXPECTED_VALUE == input_at_last_location) ) 2030 * { 2031 * result = 1; 2032 * } 2033 * 2034 * Additionally inspect program to check that all locations are as expected. 2035 * 2036 * Test all types. Test all shader stages. 2037 **/ 2038 class VaryingLocationsTest : public TextureTestBase 2039 { 2040 public: 2041 VaryingLocationsTest(deqp::Context &context); 2042 2043 VaryingLocationsTest(deqp::Context &context, const glw::GLchar *test_name, const glw::GLchar *test_description); 2044 ~VaryingLocationsTest()2045 ~VaryingLocationsTest() 2046 { 2047 } 2048 2049 protected: 2050 /* Protected methods */ 2051 virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 2052 Utils::VaryingPassthrough &varying_passthrough); 2053 2054 virtual std::string getTestCaseName(glw::GLuint test_case_index); 2055 virtual glw::GLuint getTestCaseNumber(); 2056 virtual bool isComputeRelevant(glw::GLuint test_case_index); 2057 virtual bool useMonolithicProgram(glw::GLuint test_case_index); 2058 2059 /* To be implemented by children */ 2060 virtual void prepareShaderStage(Utils::Shader::STAGES stage, const Utils::Type &type, 2061 Utils::ProgramInterface &program_interface, 2062 Utils::VaryingPassthrough &varying_passthrough); 2063 2064 /* Protected methods */ 2065 std::string prepareGlobals(glw::GLint last_in_loc, glw::GLint last_out_loc); 2066 2067 /* Protected fields */ 2068 std::vector<glw::GLubyte> m_first_data; 2069 std::vector<glw::GLubyte> m_last_data; 2070 }; 2071 2072 /** Implementation of test VertexAttribLocations. Description follows: 2073 * 2074 * Test verifies that drawing operations provide vertex attributes at expected 2075 * locations. 2076 * 2077 * This test implements Texture algorithm. Use separate shader objects instead 2078 * of monolithic program. Tessellation stages are not necessary and can be 2079 * omitted. Test following code snippet: 2080 * 2081 * layout (location = 2) in uint vertex_index; 2082 * layout (location = 5) in uint instance_index; 2083 * 2084 * if ( (gl_VertexID == vertex_index) && 2085 * (gl_InstanceID == instance_index) ) 2086 * { 2087 * result = 1; 2088 * } 2089 * 2090 * Test following Draw* operations: 2091 * - DrawArrays, 2092 * - DrawArraysInstanced, 2093 * - DrawElements, 2094 * - DrawElementsBaseVertex, 2095 * - DrawElementsInstanced, 2096 * - DrawElementsInstancedBaseInstance, 2097 * - DrawElementsInstancedBaseVertex, 2098 * - DrawElementsInstancedBaseVertexBaseInstance. 2099 * 2100 * Number of drawn instances should be equal 4. base_vertex parameter should be 2101 * set to 4. base_instance should be set to 2. 2102 * 2103 * Values provided for "vertex_index" should match index of vertex. Values 2104 * provided for "instance_index" should match index of instance 2105 * (use VertexAttribDivisor). 2106 **/ 2107 class VertexAttribLocationsTest : public TextureTestBase 2108 { 2109 public: 2110 VertexAttribLocationsTest(deqp::Context &context); 2111 ~VertexAttribLocationsTest()2112 ~VertexAttribLocationsTest() 2113 { 2114 } 2115 2116 protected: 2117 /* Protected methods */ 2118 virtual void executeDrawCall(glw::GLuint test_case_index); 2119 2120 virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 2121 Utils::VaryingPassthrough &varying_passthrough); 2122 2123 virtual std::string getTestCaseName(glw::GLuint test_case_index); 2124 virtual glw::GLuint getTestCaseNumber(); 2125 2126 virtual std::string getVerificationSnippet(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 2127 Utils::Shader::STAGES stage); 2128 2129 virtual bool isComputeRelevant(glw::GLuint test_case_index); 2130 2131 virtual void prepareAttributes(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 2132 Utils::Buffer &buffer, Utils::VertexArray &vao); 2133 2134 virtual bool useMonolithicProgram(glw::GLuint test_case_index); 2135 2136 private: 2137 /* Private enums */ 2138 enum TESTCASES 2139 { 2140 DRAWARRAYS, 2141 DRAWARRAYSINSTANCED, 2142 DRAWELEMENTS, 2143 DRAWELEMENTSBASEVERTEX, 2144 DRAWELEMENTSINSTANCED, 2145 DRAWELEMENTSINSTANCEDBASEINSTANCE, 2146 DRAWELEMENTSINSTANCEDBASEVERTEX, 2147 DRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCE, 2148 2149 /* */ 2150 TESTCASES_MAX 2151 }; 2152 2153 /* Private constants */ 2154 static const glw::GLuint m_base_vertex; 2155 static const glw::GLuint m_base_instance; 2156 static const glw::GLuint m_loc_vertex; 2157 static const glw::GLuint m_loc_instance; 2158 static const glw::GLuint m_n_instances; 2159 }; 2160 2161 /** Implementation of test VaryingArrayLocations. Description follows: 2162 * 2163 * VaryingArrayLocations 2164 * 2165 * Test verifies that locations of arrays of "varying" are assigned as declared 2166 * in shader. 2167 * 2168 * This test implements Texture algorithm. Use separate shader objects instead 2169 * of monolithic program. Test following code snippet: 2170 * 2171 * layout(location = 0) in type in_at_first_loc[FIRST_LENGTH]; 2172 * layout(location = last_input) in type in_at_last_loc[LAST_LENGTH]; 2173 * layout(location = 1) out type out_at_first_loc[FIRST_LENGTH]; 2174 * layout(location = last_output) out type out_at_last_loc[LAST_LENGTH]; 2175 * 2176 * for (uint i = 0u; i < in_at_first_loc.length(); ++i) 2177 * { 2178 * out_at_first_loc[i] = in_at_first_loc[i]; 2179 * 2180 * if (EXPECTED_VALUE[i] != in_at_first_loc[i]) 2181 * { 2182 * result = 0; 2183 * } 2184 * } 2185 * 2186 * for (uint i = 0u; i < in_at_last_loc.length(); ++i) 2187 * { 2188 * out_at_last_loc[i] = in_at_last_loc[i]; 2189 * 2190 * if (EXPECTED_VALUE[i] != in_at_last_loc[i]) 2191 * { 2192 * result = 0; 2193 * } 2194 * } 2195 * 2196 * FIRST_LENGTH and LAST_LENGTH values should be selected so as not to exceed 2197 * limits. 2198 * 2199 * Additionally inspect program to check that all locations are as expected. 2200 * 2201 * Test all types. Test all shader stages. 2202 **/ 2203 class VaryingArrayLocationsTest : public VaryingLocationsTest 2204 { 2205 public: 2206 VaryingArrayLocationsTest(deqp::Context &context); 2207 ~VaryingArrayLocationsTest()2208 ~VaryingArrayLocationsTest() 2209 { 2210 } 2211 2212 protected: 2213 /* Protected methods */ 2214 virtual void prepareShaderStage(Utils::Shader::STAGES stage, const Utils::Type &type, 2215 Utils::ProgramInterface &program_interface, 2216 Utils::VaryingPassthrough &varying_passthrough); 2217 }; 2218 2219 /** Implementation of test VaryingStructureLocations. Description follows: 2220 * 2221 * Test verifies that structures locations are as expected. 2222 * 2223 * This test implements Texture algorithm. Use separate shader objects instead 2224 * of monolithic program. Test following code snippet: 2225 * 2226 * struct Data 2227 * { 2228 * type single; 2229 * type array[ARRAY_LENGTH]; 2230 * }; 2231 * 2232 * layout (location = INPUT_LOCATION) in Data input[VARYING_LENGTH]; 2233 * layout (location = OUTPUT_LOCATION) out Data output[VARYING_LENGTH]; 2234 * 2235 * if ( (EXPECTED_VALUE == input[0].single) && 2236 * (EXPECTED_VALUE == input[0].array[0]) && 2237 * (EXPECTED_VALUE == input[0].array[last]) && 2238 * (EXPECTED_VALUE == input[last].single) && 2239 * (EXPECTED_VALUE == input[last].array[0]) && 2240 * (EXPECTED_VALUE == input[last].array[last]) ) 2241 * { 2242 * result = 1; 2243 * } 2244 * 2245 * output[0].single = input[0].single; 2246 * output[0].array[0] = input[0].array[0]; 2247 * output[0].array[last] = input[0].array[last]; 2248 * output[last].single = input[last].single; 2249 * output[last].array[0] = input[last].array[0]; 2250 * output[last].array[last] = input[last].array[last]; 2251 * 2252 * Select array lengths and locations so as no limits are exceeded. 2253 **/ 2254 2255 class VaryingStructureLocationsTest : public TextureTestBase 2256 { 2257 public: 2258 VaryingStructureLocationsTest(deqp::Context &context); 2259 ~VaryingStructureLocationsTest()2260 ~VaryingStructureLocationsTest() 2261 { 2262 } 2263 2264 protected: 2265 /* Protected methods */ 2266 virtual std::string getPassSnippet(glw::GLuint test_case_index, Utils::VaryingPassthrough &varying_passthrough, 2267 Utils::Shader::STAGES stage); 2268 2269 virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 2270 Utils::VaryingPassthrough &varying_passthrough); 2271 2272 virtual std::string getTestCaseName(glw::GLuint test_case_index); 2273 virtual glw::GLuint getTestCaseNumber(); 2274 virtual bool isComputeRelevant(glw::GLuint test_case_index); 2275 virtual bool useMonolithicProgram(glw::GLuint test_case_index); 2276 2277 /* Protected fields */ 2278 std::vector<glw::GLubyte> m_single_data; 2279 std::vector<glw::GLubyte> m_array_data; 2280 std::vector<glw::GLubyte> m_data; 2281 }; 2282 2283 /** Implementation of test VaryingStructureMemberLocation. Description follows: 2284 * 2285 * Test verifies that it is not allowed to declare structure member at specific 2286 * location. 2287 * 2288 * Test following code snippet: 2289 * 2290 * struct Data 2291 * { 2292 * vec4 gohan; 2293 * layout (location = LOCATION) vec4 goten; 2294 * } 2295 * 2296 * in Data goku; 2297 * 2298 * Select LOCATION so as not to exceed limits. Test all shader stages. Test 2299 * both in and out varyings. 2300 * 2301 * It is expected that compilation will fail. 2302 **/ 2303 class VaryingStructureMemberLocationTest : public NegativeTestBase 2304 { 2305 public: 2306 VaryingStructureMemberLocationTest(deqp::Context &context); 2307 ~VaryingStructureMemberLocationTest()2308 ~VaryingStructureMemberLocationTest() 2309 { 2310 } 2311 2312 protected: 2313 /* Methods to be implemented by child class */ 2314 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 2315 2316 virtual std::string getTestCaseName(glw::GLuint test_case_index); 2317 virtual glw::GLuint getTestCaseNumber(); 2318 virtual bool isComputeRelevant(glw::GLuint test_case_index); 2319 virtual void testInit(); 2320 2321 private: 2322 /* Private types */ 2323 struct testCase 2324 { 2325 bool m_is_input; 2326 Utils::Shader::STAGES m_stage; 2327 }; 2328 2329 /* Private fields */ 2330 std::vector<testCase> m_test_cases; 2331 }; 2332 2333 /** Implementation of test VaryingBlockLocations. Description follows: 2334 * 2335 * Test verifies that "block varyings" locations are as expected. 2336 * 2337 * This test implements Texture algorithm. Use separate shader objects instead 2338 * of monolithic program. Test following code snippet: 2339 * 2340 * layout (location = GOKU_LOCATION) in Goku 2341 * { 2342 * vec4 gohan; 2343 * layout (location = GOTEN_LOCATION) vec4 goten; 2344 * vec4 chichi; 2345 * }; 2346 * 2347 * layout (location = VEGETA_LOCATION) out Vegeta 2348 * { 2349 * vec4 trunks; 2350 * layout (location = BRA_LOCATION) vec4 bra; 2351 * vec4 bulma; 2352 * }; 2353 * 2354 * if ( (EXPECTED_VALUE == gohan) && 2355 * (EXPECTED_VALUE == goten) && 2356 * (EXPECTED_VALUE == chichi) ) 2357 * { 2358 * result = 1; 2359 * } 2360 * 2361 * trunks = gohan; 2362 * bra = goten; 2363 * bulma = chichi; 2364 * 2365 * Select all locations so as not to cause any conflicts or exceed limits. 2366 **/ 2367 class VaryingBlockLocationsTest : public TextureTestBase 2368 { 2369 public: 2370 VaryingBlockLocationsTest(deqp::Context &context); ~VaryingBlockLocationsTest()2371 ~VaryingBlockLocationsTest() 2372 { 2373 } 2374 2375 protected: 2376 /* Protected methods */ 2377 virtual std::string getPassSnippet(glw::GLuint test_case_index, Utils::VaryingPassthrough &varying_passthrough, 2378 Utils::Shader::STAGES stage); 2379 2380 virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 2381 Utils::VaryingPassthrough &varying_passthrough); 2382 2383 virtual bool isComputeRelevant(glw::GLuint test_case_index); 2384 virtual bool useMonolithicProgram(glw::GLuint test_case_index); 2385 2386 /* Protected fields */ 2387 std::vector<glw::GLubyte> m_third_data; 2388 std::vector<glw::GLubyte> m_fourth_data; 2389 std::vector<glw::GLubyte> m_fifth_data; 2390 std::vector<glw::GLubyte> m_data; 2391 }; 2392 2393 /** Implementation of test VaryingBlockMemberLocations. Description follows: 2394 * 2395 * Test verifies that it is a compilation error to declare some of block 2396 * members with location qualifier, but not all, when there is no "block level" 2397 * location qualifier. 2398 * 2399 * Test following code snippets: 2400 * 2401 * in Goku 2402 * { 2403 * vec4 gohan; 2404 * layout (location = GOTEN_LOCATION) vec4 goten; 2405 * vec4 chichi; 2406 * }; 2407 * 2408 * , 2409 * 2410 * in Goku 2411 * { 2412 * layout (location = GOHAN_LOCATION) vec4 gohan; 2413 * layout (location = GOTEN_LOCATION) vec4 goten; 2414 * layout (location = CHICHI_LOCATION) vec4 chichi; 2415 * }; 2416 * 2417 * Select all locations so as not to exceed any limits. 2418 * 2419 * It is expected that compilation of first snippet will fail. Compilation of 2420 * second snippet should be successful. 2421 * 2422 * Test all shader stages. Test both in and out blocks. 2423 **/ 2424 class VaryingBlockMemberLocationsTest : public NegativeTestBase 2425 { 2426 public: 2427 /* Public methods */ 2428 VaryingBlockMemberLocationsTest(deqp::Context &context); 2429 ~VaryingBlockMemberLocationsTest()2430 virtual ~VaryingBlockMemberLocationsTest() 2431 { 2432 } 2433 2434 protected: 2435 /* Methods to be implemented by child class */ 2436 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 2437 2438 virtual std::string getTestCaseName(glw::GLuint test_case_index); 2439 virtual glw::GLuint getTestCaseNumber(); 2440 virtual bool isComputeRelevant(glw::GLuint test_case_index); 2441 virtual bool isFailureExpected(glw::GLuint test_case_index); 2442 virtual void testInit(); 2443 2444 private: 2445 /* Private types */ 2446 struct testCase 2447 { 2448 bool m_is_input; 2449 bool m_qualify_all; 2450 Utils::Shader::STAGES m_stage; 2451 }; 2452 2453 /* Private fields */ 2454 std::vector<testCase> m_test_cases; 2455 }; 2456 2457 /** Implementation of test VaryingBlockAutomaticMemberLocations. Description follows: 2458 * 2459 * Test verifies that compiler will assign subsequent locations to block 2460 * members. 2461 * 2462 * Test following code snippet: 2463 * 2464 * layout (location = 2) in DBZ 2465 * { 2466 * vec4 goku; // 2 2467 * vec4 gohan[GOHAN_LENGTH]; // 3 2468 * vec4 goten; // 3 + GOHAN_LENGTH 2469 * layout (location = 1) vec4 chichi; // 1 2470 * vec4 pan; // 2; ERROR location 2 used twice 2471 * }; 2472 * 2473 * Test all shader stages. Test both in and out blocks. 2474 * 2475 * It is expected that build process will fail. 2476 **/ 2477 class VaryingBlockAutomaticMemberLocationsTest : public NegativeTestBase 2478 { 2479 public: 2480 /* Public methods */ 2481 VaryingBlockAutomaticMemberLocationsTest(deqp::Context &context); 2482 ~VaryingBlockAutomaticMemberLocationsTest()2483 virtual ~VaryingBlockAutomaticMemberLocationsTest() 2484 { 2485 } 2486 2487 protected: 2488 /* Methods to be implemented by child class */ 2489 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 2490 2491 virtual std::string getTestCaseName(glw::GLuint test_case_index); 2492 virtual glw::GLuint getTestCaseNumber(); 2493 virtual bool isComputeRelevant(glw::GLuint test_case_index); 2494 virtual void testInit(); 2495 2496 private: 2497 /* Private types */ 2498 struct testCase 2499 { 2500 bool m_is_input; 2501 Utils::Shader::STAGES m_stage; 2502 }; 2503 2504 /* Private fields */ 2505 std::vector<testCase> m_test_cases; 2506 }; 2507 2508 /** Implementation of test VaryingLocationLimit. Description follows: 2509 * 2510 * Test verifies that "location" qualifier cannot exceed limits. 2511 * 2512 * Test following code snippet: 2513 * 2514 * layout (location = LAST + 1) in type goku; 2515 * 2516 * LAST should be set to index of last available location. 2517 * 2518 * Test all types. Test all shader stages. Test both in and out varyings. 2519 * 2520 * It is expected that shader compilation will fail. 2521 **/ 2522 class VaryingLocationLimitTest : public NegativeTestBase 2523 { 2524 public: 2525 /* Public methods */ 2526 VaryingLocationLimitTest(deqp::Context &context); 2527 ~VaryingLocationLimitTest()2528 virtual ~VaryingLocationLimitTest() 2529 { 2530 } 2531 2532 protected: 2533 /* Methods to be implemented by child class */ 2534 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 2535 2536 virtual std::string getTestCaseName(glw::GLuint test_case_index); 2537 virtual glw::GLuint getTestCaseNumber(); 2538 virtual bool isComputeRelevant(glw::GLuint test_case_index); 2539 virtual bool isSeparable(const glw::GLuint test_case_index); 2540 virtual void testInit(); 2541 2542 private: 2543 /* Private types */ 2544 struct testCase 2545 { 2546 bool m_is_input; 2547 Utils::Type m_type; 2548 Utils::Shader::STAGES m_stage; 2549 }; 2550 2551 /* Private fields */ 2552 std::vector<testCase> m_test_cases; 2553 }; 2554 2555 /** Implementation of test VaryingComponents. Description follows: 2556 * 2557 * VaryingComponents 2558 * 2559 * Test verifies that "varying" can be assigned to specific components. 2560 * 2561 * Modify VaryingLocations to test all possible combinations of components 2562 * layout: 2563 * - g64vec2 2564 * - g64scalar, g64scalar 2565 * - gvec4 2566 * - scalar, gvec3 2567 * - gvec3, scalar 2568 * - gvec2, gvec2 2569 * - gvec2, scalar, scalar 2570 * - scalar, gvec2, scalar 2571 * - scalar, scalar, gvec2 2572 * - scalar, scalar, scalar, scalar. 2573 * 2574 * Additionally inspect program to check that all locations and components are 2575 * as expected. 2576 **/ 2577 class VaryingComponentsTest : public VaryingLocationsTest 2578 { 2579 public: 2580 VaryingComponentsTest(deqp::Context &context); 2581 2582 VaryingComponentsTest(deqp::Context &context, const glw::GLchar *test_name, const glw::GLchar *test_description); 2583 ~VaryingComponentsTest()2584 ~VaryingComponentsTest() 2585 { 2586 } 2587 2588 protected: 2589 /* Protected methods */ 2590 virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 2591 Utils::VaryingPassthrough &varying_passthrough); 2592 2593 virtual std::string getTestCaseName(glw::GLuint test_case_index); 2594 virtual glw::GLuint getTestCaseNumber(); 2595 virtual void testInit(); 2596 virtual bool useComponentQualifier(glw::GLuint test_case_index); 2597 2598 /* To be implemented by children */ 2599 virtual glw::GLuint getArrayLength(); 2600 2601 private: 2602 /* Private enums */ 2603 enum COMPONENTS_LAYOUT 2604 { 2605 G64VEC2, 2606 G64SCALAR_G64SCALAR, 2607 GVEC4, 2608 SCALAR_GVEC3, 2609 GVEC3_SCALAR, 2610 GVEC2_GVEC2, 2611 GVEC2_SCALAR_SCALAR, 2612 SCALAR_GVEC2_SCALAR, 2613 SCALAR_SCALAR_GVEC2, 2614 SCALAR_SCALAR_SCALAR_SCALAR, 2615 }; 2616 2617 /* Private struct */ 2618 struct descriptor 2619 { 2620 void assign(glw::GLint component, const glw::GLchar *component_str, glw::GLint location, 2621 const glw::GLchar *location_str, glw::GLuint n_rows, const glw::GLchar *name); 2622 2623 glw::GLint m_component; 2624 const glw::GLchar *m_component_str; 2625 glw::GLint m_location; 2626 const glw::GLchar *m_location_str; 2627 glw::GLuint m_n_rows; 2628 const glw::GLchar *m_name; 2629 }; 2630 2631 struct testCase 2632 { 2633 testCase(COMPONENTS_LAYOUT layout, Utils::Type::TYPES type); 2634 2635 COMPONENTS_LAYOUT m_layout; 2636 Utils::Type::TYPES m_type; 2637 }; 2638 2639 /* Private routines */ 2640 std::string prepareGlobals(glw::GLuint last_in_location, glw::GLuint last_out_location); 2641 2642 std::string prepareName(const glw::GLchar *name, glw::GLint location, glw::GLint component, 2643 Utils::Shader::STAGES stage, Utils::Variable::STORAGE storage); 2644 2645 std::string prepareQualifiers(const glw::GLchar *location, const glw::GLchar *component, 2646 const glw::GLchar *interpolation); 2647 2648 using VaryingLocationsTest::prepareShaderStage; 2649 2650 void prepareShaderStage(Utils::Shader::STAGES stage, const Utils::Type &vector_type, 2651 Utils::ProgramInterface &program_interface, const testCase &test_case, 2652 Utils::VaryingPassthrough &varying_passthrough); 2653 2654 Utils::Variable *prepareVarying(const Utils::Type &basic_type, const descriptor &desc, 2655 const glw::GLchar *interpolation, Utils::ShaderInterface &si, 2656 Utils::Shader::STAGES stage, Utils::Variable::STORAGE storage); 2657 2658 /* Private fields */ 2659 std::vector<testCase> m_test_cases; 2660 std::vector<glw::GLubyte> m_data; 2661 }; 2662 2663 /** Implementation of test VaryingArrayComponents. Description follows: 2664 * 2665 * Test verifies that arrays of "varyings" can be assigned to specific 2666 * components. 2667 * 2668 * Modify VaryingComponents similarly to VaryingArrayLocations. 2669 **/ 2670 class VaryingArrayComponentsTest : public VaryingComponentsTest 2671 { 2672 public: 2673 VaryingArrayComponentsTest(deqp::Context &context); 2674 ~VaryingArrayComponentsTest()2675 ~VaryingArrayComponentsTest() 2676 { 2677 } 2678 2679 protected: 2680 /* Protected methods */ 2681 virtual glw::GLuint getArrayLength(); 2682 }; 2683 2684 /** Implementation of test VaryingInvalidValueComponent. Description follows: 2685 * 2686 * Test verifies that it is not allowed to use some component values 2687 * with specific types. 2688 * 2689 * Test following code snippets: 2690 * 2691 * layout (location = 1, component = COMPONENT) in type gohan; 2692 * 2693 * and 2694 * 2695 * layout (location = 1, component = COMPONENT) in type gohan[LENGTH]; 2696 * 2697 * Select COMPONENT so it is an invalid value either due the specific 2698 * restrictions of each type, eg. 2 for vec4, which overflows the 2699 * amount of components in a location. Select array length so as to 2700 * not exceed limits of available locations. 2701 * 2702 * Test all types. Test all shader stages. Test both in and out varyings. 2703 * 2704 * It is expected that build process will fail. 2705 **/ 2706 class VaryingInvalidValueComponentTest : public NegativeTestBase 2707 { 2708 public: 2709 /* Public methods */ 2710 VaryingInvalidValueComponentTest(deqp::Context &context); 2711 ~VaryingInvalidValueComponentTest()2712 virtual ~VaryingInvalidValueComponentTest() 2713 { 2714 } 2715 2716 protected: 2717 /* Methods to be implemented by child class */ 2718 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 2719 2720 virtual std::string getTestCaseName(glw::GLuint test_case_index); 2721 virtual glw::GLuint getTestCaseNumber(); 2722 virtual bool isComputeRelevant(glw::GLuint test_case_index); 2723 virtual void testInit(); 2724 2725 private: 2726 /* Private types */ 2727 struct testCase 2728 { 2729 glw::GLuint m_component; 2730 bool m_is_input; 2731 bool m_is_array; 2732 Utils::Shader::STAGES m_stage; 2733 Utils::Type m_type; 2734 }; 2735 2736 /* Private fields */ 2737 std::vector<testCase> m_test_cases; 2738 }; 2739 2740 /** Implementation of test VaryingExceedingComponents. Description follows: 2741 * 2742 * Test verifies that it is not allowed to use a value that exceeds 2743 * the amount of possible components in a location. 2744 * 2745 * Test following code snippets: 2746 * 2747 * layout (location = 1, component = 4) in type gohan; 2748 * 2749 * and 2750 * 2751 * layout (location = 1, component = 4) in type gohan[LENGTH]; 2752 * 2753 * Select array length so as to not exceed limits of available locations. 2754 * 2755 * Test all types. Test all shader stages. Test both in and out varyings. 2756 * 2757 * It is expected that build process will fail. 2758 **/ 2759 class VaryingExceedingComponentsTest : public NegativeTestBase 2760 { 2761 public: 2762 /* Public methods */ 2763 VaryingExceedingComponentsTest(deqp::Context &context); 2764 ~VaryingExceedingComponentsTest()2765 virtual ~VaryingExceedingComponentsTest() 2766 { 2767 } 2768 2769 protected: 2770 /* Methods to be implemented by child class */ 2771 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 2772 2773 virtual std::string getTestCaseName(glw::GLuint test_case_index); 2774 virtual glw::GLuint getTestCaseNumber(); 2775 virtual bool isComputeRelevant(glw::GLuint test_case_index); 2776 virtual void testInit(); 2777 2778 private: 2779 /* Private types */ 2780 struct testCase 2781 { 2782 bool m_is_input; 2783 bool m_is_array; 2784 Utils::Shader::STAGES m_stage; 2785 Utils::Type m_type; 2786 }; 2787 2788 /* Private fields */ 2789 std::vector<testCase> m_test_cases; 2790 }; 2791 2792 /** Implementation of test VaryingComponentWithoutLocation. Description follows: 2793 * 2794 * Test verifies that "component" qualifier cannot be used without "location" 2795 * qualifier. 2796 * 2797 * Test following code snippet: 2798 * 2799 * layout (component = COMPONENT) in type goku; 2800 * 2801 * Test all types. Test all valid COMPONENT values. Test all shader stages. 2802 * Test both in and out varyings. 2803 * 2804 * It is expected that shader compilation will fail. 2805 **/ 2806 class VaryingComponentWithoutLocationTest : public NegativeTestBase 2807 { 2808 public: 2809 /* Public methods */ 2810 VaryingComponentWithoutLocationTest(deqp::Context &context); 2811 ~VaryingComponentWithoutLocationTest()2812 virtual ~VaryingComponentWithoutLocationTest() 2813 { 2814 } 2815 2816 protected: 2817 /* Methods to be implemented by child class */ 2818 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 2819 2820 virtual std::string getTestCaseName(glw::GLuint test_case_index); 2821 virtual glw::GLuint getTestCaseNumber(); 2822 virtual bool isComputeRelevant(glw::GLuint test_case_index); 2823 virtual void testInit(); 2824 2825 private: 2826 /* Private types */ 2827 struct testCase 2828 { 2829 glw::GLuint m_component; 2830 bool m_is_input; 2831 Utils::Shader::STAGES m_stage; 2832 Utils::Type m_type; 2833 }; 2834 2835 /* Private fields */ 2836 std::vector<testCase> m_test_cases; 2837 }; 2838 2839 /** Implementation of test VaryingComponentOfInvalidType. Description follows: 2840 * 2841 * Test verifies that it is not allowed to declare matrix, struct, block and 2842 * array of those at specific component. 2843 * 2844 * Test following code snippets: 2845 * 2846 * layout (location = 0, component = COMPONENT) in matrix_type varying; 2847 * 2848 * , 2849 * 2850 * layout (location = 0, component = COMPONENT) 2851 * in matrix_type varying[LENGTH]; 2852 * 2853 * , 2854 * 2855 * layout (location = 0, component = COMPONENT) in Block 2856 * { 2857 * type member; 2858 * }; 2859 * 2860 * , 2861 * 2862 * layout (location = 0, component = COMPONENT) in Block 2863 * { 2864 * type member; 2865 * } block[LENGTH]; 2866 * 2867 * , 2868 * 2869 * struct Data 2870 * { 2871 * type member; 2872 * }; 2873 * 2874 * layout (location = 0, component = COMPONENT) in Data varying; 2875 * 2876 * and 2877 * 2878 * struct Data 2879 * { 2880 * type member; 2881 * }; 2882 * 2883 * layout (location = 0, component = COMPONENT) in Data varying[LENGTH]; 2884 * 2885 * Test all types. Test all shader stages. Test both in and out varyings. 2886 * 2887 * It is expected that build process will fail. 2888 **/ 2889 class VaryingComponentOfInvalidTypeTest : public NegativeTestBase 2890 { 2891 public: 2892 /* Public methods */ 2893 VaryingComponentOfInvalidTypeTest(deqp::Context &context); 2894 ~VaryingComponentOfInvalidTypeTest()2895 virtual ~VaryingComponentOfInvalidTypeTest() 2896 { 2897 } 2898 2899 protected: 2900 /* Methods to be implemented by child class */ 2901 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 2902 2903 virtual std::string getTestCaseName(glw::GLuint test_case_index); 2904 virtual glw::GLuint getTestCaseNumber(); 2905 2906 virtual bool isComputeRelevant(glw::GLuint test_case_index); 2907 virtual void testInit(); 2908 2909 private: 2910 /* Private enums */ 2911 enum CASES 2912 { 2913 MATRIX = 0, 2914 DVEC3_DVEC4, 2915 BLOCK, 2916 STRUCT, 2917 2918 /* */ 2919 MAX_CASES 2920 }; 2921 2922 /* Private types */ 2923 struct testCase 2924 { 2925 CASES m_case; 2926 glw::GLuint m_component; 2927 bool m_is_array; 2928 bool m_is_input; 2929 Utils::Shader::STAGES m_stage; 2930 Utils::Type m_type; 2931 }; 2932 2933 /* Private fields */ 2934 std::vector<testCase> m_test_cases; 2935 }; 2936 2937 /** Implementation of test InputComponentAliasing. Description follows: 2938 * 2939 * Test verifies that component aliasing cause compilation or linking error. 2940 * 2941 * Test following code snippet: 2942 * 2943 * layout (location = 1, component = GOHAN_COMPONENT) in type gohan; 2944 * layout (location = 1, component = GOTEN_COMPONENT) in type goten; 2945 * 2946 * if (EXPECTED_VALUE == gohan) 2947 * { 2948 * result = 1; 2949 * } 2950 * 2951 * Test all components combinations that cause aliasing. Test all types. Test 2952 * all shader stages. It is expected that build process will fail. 2953 * 2954 * Vertex shader allows component aliasing on input as long as only one of the 2955 * attributes is used in each execution path. Test vertex shader stage with two 2956 * variants: 2957 * - first as presented above, 2958 * - second, where "result = 1;" is replaced with "result = goten;". 2959 * In first case build process should succeed, in the second case build process 2960 * should fail. 2961 **/ 2962 class InputComponentAliasingTest : public NegativeTestBase 2963 { 2964 public: 2965 /* Public methods */ 2966 InputComponentAliasingTest(deqp::Context &context); 2967 ~InputComponentAliasingTest()2968 virtual ~InputComponentAliasingTest() 2969 { 2970 } 2971 2972 protected: 2973 /* Methods to be implemented by child class */ 2974 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 2975 2976 virtual std::string getTestCaseName(glw::GLuint test_case_index); 2977 virtual glw::GLuint getTestCaseNumber(); 2978 2979 virtual bool isComputeRelevant(glw::GLuint test_case_index); 2980 virtual bool isFailureExpected(glw::GLuint test_case_index); 2981 virtual void testInit(); 2982 2983 private: 2984 /* Private types */ 2985 struct testCase 2986 { 2987 glw::GLuint m_component_gohan; 2988 glw::GLuint m_component_goten; 2989 Utils::Shader::STAGES m_stage; 2990 Utils::Type m_type; 2991 }; 2992 2993 /* Private fields */ 2994 std::vector<testCase> m_test_cases; 2995 }; 2996 2997 /** Implementation of test OutputComponentAliasing. Description follows: 2998 * 2999 * Test verifies that component aliasing cause compilation or linking error. 3000 * 3001 * Test following code snippet: 3002 * 3003 * layout (location = 1, component = GOHAN_COMPONENT) out type gohan; 3004 * layout (location = 1, component = GOTEN_COMPONENT) out type goten; 3005 * 3006 * gohan = GOHAN_VALUE; 3007 * goten = GOTEN_VALUE; 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 class OutputComponentAliasingTest : public NegativeTestBase 3013 { 3014 public: 3015 /* Public methods */ 3016 OutputComponentAliasingTest(deqp::Context &context); 3017 ~OutputComponentAliasingTest()3018 virtual ~OutputComponentAliasingTest() 3019 { 3020 } 3021 3022 protected: 3023 /* Methods to be implemented by child class */ 3024 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 3025 3026 virtual std::string getTestCaseName(glw::GLuint test_case_index); 3027 virtual glw::GLuint getTestCaseNumber(); 3028 virtual bool isComputeRelevant(glw::GLuint test_case_index); 3029 virtual void testInit(); 3030 3031 private: 3032 /* Private types */ 3033 struct testCase 3034 { 3035 glw::GLuint m_component_gohan; 3036 glw::GLuint m_component_goten; 3037 Utils::Shader::STAGES m_stage; 3038 Utils::Type m_type; 3039 }; 3040 3041 /* Private fields */ 3042 std::vector<testCase> m_test_cases; 3043 }; 3044 3045 /** Implementation of test VaryingLocationAliasingWithMixedTypes. Description follows: 3046 * 3047 * Test verifies that it is not allowed to mix integer and float base types at 3048 * aliased location. 3049 * 3050 * Test following code snippet: 3051 * 3052 * layout (location = 1, component = GOHAN_COMPONENT) in gohan_type gohan; 3053 * layout (location = 1, component = GOTEN_COMPONENT) in goten_type goten; 3054 * 3055 * Test all components combinations that do not cause component aliasing. Test 3056 * all types combinations that cause float/integer conflict. Test all shader 3057 * stages. Test both in and out varyings. 3058 * 3059 * It is expected that build process will fail. 3060 **/ 3061 class VaryingLocationAliasingWithMixedTypesTest : public NegativeTestBase 3062 { 3063 public: 3064 /* Public methods */ 3065 VaryingLocationAliasingWithMixedTypesTest(deqp::Context &context); 3066 ~VaryingLocationAliasingWithMixedTypesTest()3067 virtual ~VaryingLocationAliasingWithMixedTypesTest() 3068 { 3069 } 3070 3071 protected: 3072 /* Methods to be implemented by child class */ 3073 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 3074 3075 virtual std::string getTestCaseName(glw::GLuint test_case_index); 3076 virtual glw::GLuint getTestCaseNumber(); 3077 virtual bool isComputeRelevant(glw::GLuint test_case_index); 3078 virtual void testInit(); 3079 3080 private: 3081 /* Private types */ 3082 struct testCase 3083 { 3084 glw::GLuint m_component_gohan; 3085 glw::GLuint m_component_goten; 3086 bool m_is_input; 3087 Utils::Shader::STAGES m_stage; 3088 Utils::Type m_type_gohan; 3089 Utils::Type m_type_goten; 3090 }; 3091 3092 /* Private fields */ 3093 std::vector<testCase> m_test_cases; 3094 }; 3095 3096 /** Implementation of test VaryingLocationAliasingWithMixedInterpolation. Description follows: 3097 * 3098 * Test verifies that it is not allowed to mix interpolation methods at aliased 3099 * location. 3100 * 3101 * Test following code snippet: 3102 * 3103 * layout (location = 1, component = GOHAN_COMPONENT) 3104 * GOHAN_INTERPOLATION in type gohan; 3105 * layout (location = 1, component = GOTEN_COMPONENT) 3106 * GOTEN_INTERPOLATION in type goten; 3107 * 3108 * Test all interpolation combinations that cause conflict. Select components 3109 * so as not to cause component aliasing. Test all types. Test all shader 3110 * stages. Test both in and out varyings. 3111 * 3112 * Note, that vertex shader's input and fragment shader's output cannot be 3113 * qualified with interpolation method. 3114 * 3115 * It is expected that build process will fail. 3116 **/ 3117 class VaryingLocationAliasingWithMixedInterpolationTest : public NegativeTestBase 3118 { 3119 public: 3120 /* Public methods */ 3121 VaryingLocationAliasingWithMixedInterpolationTest(deqp::Context &context); 3122 ~VaryingLocationAliasingWithMixedInterpolationTest()3123 virtual ~VaryingLocationAliasingWithMixedInterpolationTest() 3124 { 3125 } 3126 3127 protected: 3128 /* Methods to be implemented by child class */ 3129 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 3130 3131 virtual std::string getTestCaseName(glw::GLuint test_case_index); 3132 virtual glw::GLuint getTestCaseNumber(); 3133 virtual bool isComputeRelevant(glw::GLuint test_case_index); 3134 virtual void testInit(); 3135 3136 private: 3137 enum INTERPOLATIONS 3138 { 3139 SMOOTH = 0, 3140 FLAT, 3141 NO_PERSPECTIVE, 3142 3143 /* */ 3144 INTERPOLATION_MAX 3145 }; 3146 3147 /* Private types */ 3148 struct testCase 3149 { 3150 glw::GLuint m_component_gohan; 3151 glw::GLuint m_component_goten; 3152 INTERPOLATIONS m_interpolation_gohan; 3153 INTERPOLATIONS m_interpolation_goten; 3154 bool m_is_input; 3155 Utils::Shader::STAGES m_stage; 3156 Utils::Type m_type_gohan; 3157 Utils::Type m_type_goten; 3158 }; 3159 3160 /* Private routines */ 3161 const glw::GLchar *getInterpolationQualifier(INTERPOLATIONS interpolation); 3162 3163 /* Private fields */ 3164 std::vector<testCase> m_test_cases; 3165 }; 3166 3167 /** Implementation of test VaryingLocationAliasingWithMixedAuxiliaryStorage. Description follows: 3168 * 3169 * Test verifies that it is not allowed to mix auxiliary storage at aliased 3170 * location. 3171 * 3172 * Test following code snippet: 3173 * 3174 * layout (location = 1, component = GOHAN_COMPONENT) 3175 * GOHAN_AUXILIARY in type gohan; 3176 * layout (location = 1, component = GOTEN_COMPONENT) 3177 * GOTEN_AUXILIARY in type goten; 3178 * 3179 * Test all auxiliary storage combinations that cause conflict. Select 3180 * components so as not to cause component aliasing. Test all types. Test all 3181 * shader stages. Test both in and out varyings. 3182 * 3183 * It is expected that build process will fail. 3184 **/ 3185 class VaryingLocationAliasingWithMixedAuxiliaryStorageTest : public NegativeTestBase 3186 { 3187 public: 3188 /* Public methods */ 3189 VaryingLocationAliasingWithMixedAuxiliaryStorageTest(deqp::Context &context); 3190 ~VaryingLocationAliasingWithMixedAuxiliaryStorageTest()3191 virtual ~VaryingLocationAliasingWithMixedAuxiliaryStorageTest() 3192 { 3193 } 3194 3195 protected: 3196 /* Methods to be implemented by child class */ 3197 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 3198 3199 virtual std::string getTestCaseName(glw::GLuint test_case_index); 3200 virtual glw::GLuint getTestCaseNumber(); 3201 virtual bool isComputeRelevant(glw::GLuint test_case_index); 3202 virtual void testInit(); 3203 3204 private: 3205 enum AUXILIARIES 3206 { 3207 NONE = 0, 3208 PATCH, 3209 CENTROID, 3210 SAMPLE, 3211 3212 /* */ 3213 AUXILIARY_MAX 3214 }; 3215 3216 /* Private types */ 3217 struct testCase 3218 { 3219 glw::GLuint m_component_gohan; 3220 glw::GLuint m_component_goten; 3221 AUXILIARIES m_aux_gohan; 3222 AUXILIARIES m_aux_goten; 3223 bool m_is_input; 3224 Utils::Shader::STAGES m_stage; 3225 Utils::Type m_type_gohan; 3226 Utils::Type m_type_goten; 3227 }; 3228 3229 /* Private routines */ 3230 const glw::GLchar *getAuxiliaryQualifier(AUXILIARIES aux); 3231 3232 /* Private fields */ 3233 std::vector<testCase> m_test_cases; 3234 }; 3235 3236 /** Implementation of test VertexAttribLocationAPI. Description follows: 3237 * 3238 * Test verifies that vertex attribute location API works as expected. 3239 * 3240 * This test implements Texture algorithm. Tessellation shaders are not 3241 * necessary and can be omitted. Test following code snippet in vertex shader: 3242 * 3243 * layout (location = GOKU_LOCATION) in vec4 goku; 3244 * in vec4 gohan; 3245 * in vec4 goten; 3246 * in vec4 chichi; 3247 * 3248 * if ( (EXPECTED_VALUE == goku) && 3249 * (EXPECTED_VALUE == gohan) && 3250 * (EXPECTED_VALUE == gotan) && 3251 * (EXPECTED_VALUE == chichi) ) 3252 * { 3253 * result = 1; 3254 * } 3255 * 3256 * After compilation, before program is linked, specify locations for goku, 3257 * and goten with glBindAttribLocation. Specify different location than the one 3258 * used in shader. 3259 * 3260 * Select all locations so as not to exceed any limits. 3261 * 3262 * Additionally inspect program to verify that: 3263 * - goku location is as specified in shader text, 3264 * - goten location is as specified with API. 3265 **/ 3266 class VertexAttribLocationAPITest : public TextureTestBase 3267 { 3268 public: 3269 VertexAttribLocationAPITest(deqp::Context &context); 3270 ~VertexAttribLocationAPITest()3271 ~VertexAttribLocationAPITest() 3272 { 3273 } 3274 3275 protected: 3276 /* Protected methods */ 3277 virtual void prepareAttribLocation(Utils::Program &program, Utils::ProgramInterface &program_interface); 3278 3279 virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 3280 Utils::VaryingPassthrough &varying_passthrough); 3281 3282 virtual bool isComputeRelevant(glw::GLuint test_case_index); 3283 3284 private: 3285 /* Private fields */ 3286 std::vector<glw::GLubyte> m_goku_data; 3287 std::vector<glw::GLubyte> m_gohan_data; 3288 std::vector<glw::GLubyte> m_goten_data; 3289 std::vector<glw::GLubyte> m_chichi_data; 3290 3291 /* Private constants */ 3292 static const glw::GLuint m_goten_location; 3293 }; 3294 /** Implementation of test FragmentDataLocationAPI. Description follows: 3295 * 3296 * Test verifies that fragment data location API works as expected. 3297 * 3298 * This test implements Texture algorithm. Tessellation shaders are not 3299 * necessary and can be omitted. "result" is not necessary and can be omitted. 3300 * Test following code snippet in fragment shader: 3301 * 3302 * layout (location = GOKU_LOCATION) out vec4 goku; 3303 * out vec4 gohan; 3304 * out vec4 goten; 3305 * out vec4 chichi; 3306 * 3307 * goku = EXPECTED_VALUE; 3308 * gohan = EXPECTED_VALUE; 3309 * goten = EXPECTED_VALUE; 3310 * chichi = EXPECTED_VALUE; 3311 * 3312 * After compilation, before program is linked, specify locations for goku, 3313 * and goten with glBindFragDataLocation. Specify different location than the 3314 * one used in shader. 3315 * 3316 * Select all locations so as not to exceed any limits. 3317 * 3318 * Additionally inspect program to verify that: 3319 * - goku location is as specified in shader text, 3320 * - goten location is as specified with API. 3321 **/ 3322 class FragmentDataLocationAPITest : public TextureTestBase 3323 { 3324 public: 3325 FragmentDataLocationAPITest(deqp::Context &context); 3326 ~FragmentDataLocationAPITest()3327 ~FragmentDataLocationAPITest() 3328 { 3329 } 3330 3331 protected: 3332 /* Protected methods */ 3333 virtual bool checkResults(glw::GLuint test_case_index, Utils::Texture &color_0); 3334 3335 virtual std::string getPassSnippet(glw::GLuint test_case_index, Utils::VaryingPassthrough &varying_passthrough, 3336 Utils::Shader::STAGES stage); 3337 3338 virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 3339 Utils::VaryingPassthrough &varying_passthrough); 3340 3341 virtual bool isComputeRelevant(glw::GLuint test_case_index); 3342 3343 virtual void prepareFragmentDataLoc(Utils::Program &program, Utils::ProgramInterface &program_interface); 3344 3345 virtual void prepareFramebuffer(Utils::Framebuffer &framebuffer, Utils::Texture &color_0_texture); 3346 3347 private: 3348 /* Private fields */ 3349 Utils::Texture m_goku; 3350 Utils::Texture m_gohan; 3351 Utils::Texture m_goten; 3352 Utils::Texture m_chichi; 3353 3354 glw::GLint m_goku_location; 3355 glw::GLint m_gohan_location; 3356 glw::GLint m_chichi_location; 3357 3358 /* Private constants */ 3359 static const glw::GLuint m_goten_location; 3360 }; 3361 3362 /** Implementation of test XFBInput. Description follows: 3363 * 3364 * Test verifies that using xfb_buffer, xfb_stride or xfb_offset qualifiers on 3365 * input variables will cause failure of build process. 3366 * 3367 * Test all shader stages. 3368 **/ 3369 class XFBInputTest : public NegativeTestBase 3370 { 3371 public: 3372 /* Public methods */ 3373 XFBInputTest(deqp::Context &context); ~XFBInputTest()3374 virtual ~XFBInputTest() 3375 { 3376 } 3377 3378 protected: 3379 /* Methods to be implemented by child class */ 3380 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 3381 3382 virtual std::string getTestCaseName(glw::GLuint test_case_index); 3383 virtual glw::GLuint getTestCaseNumber(); 3384 virtual bool isComputeRelevant(glw::GLuint test_case_index); 3385 virtual void testInit(); 3386 3387 private: 3388 enum QUALIFIERS 3389 { 3390 BUFFER = 0, 3391 STRIDE, 3392 OFFSET, 3393 3394 /* */ 3395 QUALIFIERS_MAX 3396 }; 3397 3398 /* Private types */ 3399 struct testCase 3400 { 3401 QUALIFIERS m_qualifier; 3402 Utils::Shader::STAGES m_stage; 3403 }; 3404 3405 /* Private fields */ 3406 std::vector<testCase> m_test_cases; 3407 }; 3408 3409 /** Implementation of test XFBAllStages. Description follows: 3410 * 3411 * Test verifies that only outputs from last stage processing primitives can be 3412 * captured with XFB. 3413 * 3414 * This test implements Buffer algorithm. Rasterization can be discarded. 3415 * 3416 * At each stage declare a single active output variable qualified with 3417 * xfb_buffer and xfb_offset = 0. Use separate buffers for each stage. 3418 * 3419 * Test pass if outputs from geometry shader are captured, while outputs from: 3420 * vertex and tessellation stages are ignored. 3421 **/ 3422 class XFBAllStagesTest : public BufferTestBase 3423 { 3424 public: 3425 XFBAllStagesTest(deqp::Context &context); 3426 ~XFBAllStagesTest()3427 ~XFBAllStagesTest() 3428 { 3429 } 3430 3431 protected: 3432 /* Protected methods */ 3433 virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector &out_descriptors); 3434 3435 virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string &out_assignments, 3436 std::string &out_calculations); 3437 3438 virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage, 3439 std::string &out_interface); 3440 3441 private: 3442 /* Constants */ 3443 static const glw::GLuint m_gs_index; 3444 }; 3445 3446 /** Implementation of test XFBStrideOfEmptyList. Description follows: 3447 * 3448 * Test verifies correct behavior when xfb_stride qualifier is specified 3449 * but no variables are qualified with xfb_offset. 3450 * 3451 * Test implements Buffer algorithm. Rasterization can be discarded. 3452 * 3453 * Test following code snippet: 3454 * 3455 * layout (xfb_buffer = 1, xfb_stride = 64) out; 3456 * 3457 * Moreover program should output something to xfb at index 0 3458 * 3459 * Test following cases: 3460 * 1 Provide buffers to XFB at index 0 and 1 3461 * 2 Provide buffer to XFB at index 1, index 0 should be missing 3462 * 3 Provide buffer to XFB at index 0, index 1 should be missing 3463 * 3464 * It is expected that: 3465 * - BeginTransformFeedback operation will report GL_INVALID_OPERATION in case 2 3466 * - XFB at index 1 will not be modified in cases 1 and 3. 3467 **/ 3468 3469 class XFBStrideOfEmptyListTest : public BufferTestBase 3470 { 3471 public: 3472 XFBStrideOfEmptyListTest(deqp::Context &context); 3473 ~XFBStrideOfEmptyListTest()3474 ~XFBStrideOfEmptyListTest() 3475 { 3476 } 3477 3478 protected: 3479 /* Protected methods */ 3480 using BufferTestBase::executeDrawCall; 3481 virtual bool executeDrawCall(bool tesEnabled, glw::GLuint test_case_index); 3482 3483 virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector &out_descriptors); 3484 3485 virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string &out_assignments, 3486 std::string &out_calculations); 3487 3488 virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage, 3489 std::string &out_interface); 3490 3491 virtual std::string getTestCaseName(glw::GLuint test_case_index); 3492 virtual glw::GLuint getTestCaseNumber(); 3493 3494 private: 3495 enum CASES 3496 { 3497 VALID = 0, 3498 FIRST_MISSING, 3499 SECOND_MISSING, 3500 }; 3501 3502 /* Private constants */ 3503 static const glw::GLuint m_stride; 3504 }; 3505 3506 /** Implementation of test XFBStrideOfEmptyListAndAPI. Description follows: 3507 * 3508 * Test verifies that xfb_stride qualifier is not overridden by API. 3509 * 3510 * Test implements Buffer algorithm. Rasterization can be discarded. 3511 * 3512 * Test following code snippet: 3513 * 3514 * layout (xfb_buffer = 0, xfb_stride = 64) out; 3515 * 3516 * Moreover program should output something to xfb at index 1 3517 3518 * Use TransformFeedbackVaryings to declare a single vec4 output variable to be 3519 * captured. 3520 * 3521 * Test following cases: 3522 * 1 Provide buffers to XFB at index 0 and 1 3523 * 2 Provide buffer to XFB at index 1, index 0 should be missing 3524 * 3 Provide buffer to XFB at index 0, index 1 should be missing 3525 * 3526 * It is expected that: 3527 * - BeginTransformFeedback operation will report GL_INVALID_OPERATION in cases 3528 * 2 and 3, 3529 * - XFB at index 0 will not be modified in case 1. 3530 **/ 3531 class XFBStrideOfEmptyListAndAPITest : public BufferTestBase 3532 { 3533 public: 3534 XFBStrideOfEmptyListAndAPITest(deqp::Context &context); 3535 ~XFBStrideOfEmptyListAndAPITest()3536 ~XFBStrideOfEmptyListAndAPITest() 3537 { 3538 } 3539 3540 protected: 3541 /* Protected methods */ 3542 using BufferTestBase::executeDrawCall; 3543 virtual bool executeDrawCall(bool tesEnabled, glw::GLuint test_case_index); 3544 virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector &out_descriptors); 3545 3546 virtual void getCapturedVaryings(glw::GLuint test_case_index, Utils::Program::NameVector &captured_varyings, 3547 glw::GLint *xfb_components); 3548 3549 virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string &out_assignments, 3550 std::string &out_calculations); 3551 3552 virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage, 3553 std::string &out_interface); 3554 3555 virtual std::string getTestCaseName(glw::GLuint test_case_index); 3556 virtual glw::GLuint getTestCaseNumber(); 3557 3558 private: 3559 enum CASES 3560 { 3561 VALID = 0, 3562 FIRST_MISSING, 3563 SECOND_MISSING, 3564 }; 3565 3566 /* Private constants */ 3567 static const glw::GLuint m_stride; 3568 }; 3569 3570 /** Implementation of test XFBTooSmallStride. Description follows: 3571 * 3572 * Test verifies that build process fails when xfb_stride qualifier sets not 3573 * enough space for all variables. 3574 * 3575 * Test following code snippets: 3576 * 3577 * layout (xfb_buffer = 0, xfb_stride = 40) out; 3578 * 3579 * layout (xfb_offset = 32) out vec4 goku; 3580 * 3581 * goku = EXPECTED_VALUE. 3582 * 3583 * , 3584 * 3585 * layout (xfb_buffer = 0, xfb_stride = 28) out; 3586 * 3587 * layout (xfb_offset = 16, xfb_stride = 28) out vec4 goku; 3588 * 3589 * goku = EXPECTED_VALUE. 3590 * 3591 * , 3592 * 3593 * layout (xfb_buffer = 0, xfb_stride = 32) out; 3594 * 3595 * layout (xfb_offset = 0) out Goku { 3596 * vec4 gohan; 3597 * vec4 goten; 3598 * vec4 chichi; 3599 * }; 3600 * 3601 * gohan = EXPECTED_VALUE; 3602 * goten = EXPECTED_VALUE; 3603 * chichi = EXPECTED_VALUE; 3604 * 3605 * , 3606 * 3607 * layout (xfb_buffer = 0, xfb_stride = 32) out; 3608 * 3609 * layout (xfb_offset = 16) out vec4 goku[4]; 3610 * 3611 * goku[0] = EXPECTED_VALUE. 3612 * goku[1] = EXPECTED_VALUE. 3613 * goku[2] = EXPECTED_VALUE. 3614 * goku[3] = EXPECTED_VALUE. 3615 * 3616 * It is expected that build process will fail. 3617 * 3618 * Test all shader stages. 3619 **/ 3620 class XFBTooSmallStrideTest : public NegativeTestBase 3621 { 3622 public: 3623 /* Public methods */ 3624 XFBTooSmallStrideTest(deqp::Context &context); 3625 ~XFBTooSmallStrideTest()3626 virtual ~XFBTooSmallStrideTest() 3627 { 3628 } 3629 3630 protected: 3631 /* Methods to be implemented by child class */ 3632 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 3633 3634 virtual std::string getTestCaseName(glw::GLuint test_case_index); 3635 virtual glw::GLuint getTestCaseNumber(); 3636 virtual bool isComputeRelevant(glw::GLuint test_case_index); 3637 virtual void testInit(); 3638 3639 private: 3640 enum CASES 3641 { 3642 OFFSET = 0, 3643 STRIDE, 3644 BLOCK, 3645 ARRAY, 3646 3647 /* */ 3648 CASE_MAX 3649 }; 3650 3651 /* Private types */ 3652 struct testCase 3653 { 3654 CASES m_case; 3655 Utils::Shader::STAGES m_stage; 3656 }; 3657 3658 /* Private fields */ 3659 std::vector<testCase> m_test_cases; 3660 }; 3661 3662 /** Implementation of test XFBVariableStride. Description follows: 3663 * 3664 * Test verifies that xfb_stride qualifier change stride of output variable. 3665 * 3666 * Test following code snippets: 3667 * 3668 * layout (xfb_stride = sizeof(type)) out; 3669 * 3670 * layout (xfb_offset = 0) out type goku; 3671 * 3672 * and 3673 * 3674 * layout (xfb_stride = sizeof(type)) out; 3675 * 3676 * layout (xfb_offset = 0) out type goku; 3677 * layout (xfb_offset = sizeof(type)) out type vegeta; 3678 * 3679 * It is expected that: 3680 * - first snippet will build successfully, 3681 * - second snippet will fail to build. 3682 * 3683 * Test all types. Test all shader stages. 3684 **/ 3685 class XFBVariableStrideTest : public NegativeTestBase 3686 { 3687 public: 3688 /* Public methods */ 3689 XFBVariableStrideTest(deqp::Context &context); ~XFBVariableStrideTest()3690 virtual ~XFBVariableStrideTest() 3691 { 3692 } 3693 3694 protected: 3695 /* Methods to be implemented by child class */ 3696 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 3697 3698 virtual std::string getTestCaseName(glw::GLuint test_case_index); 3699 virtual glw::GLuint getTestCaseNumber(); 3700 virtual bool isComputeRelevant(glw::GLuint test_case_index); 3701 virtual bool isFailureExpected(glw::GLuint test_case_index); 3702 virtual void testInit(); 3703 3704 private: 3705 enum CASES 3706 { 3707 VALID = 0, 3708 INVALID, 3709 3710 /* */ 3711 CASE_MAX 3712 }; 3713 3714 /* Private types */ 3715 struct testCase 3716 { 3717 CASES m_case; 3718 Utils::Shader::STAGES m_stage; 3719 Utils::Type m_type; 3720 }; 3721 3722 /* Private fields */ 3723 std::vector<testCase> m_test_cases; 3724 }; 3725 3726 /** Implementation of test XFBBlockStride. Description follows: 3727 * 3728 * Test verifies that xfb_stride qualifier change stride of output block. 3729 * 3730 * Test following code snippet: 3731 * 3732 * layout (xfb_offset = 0, xfb_stride = 128) out Goku { 3733 * vec4 gohan; 3734 * vec4 goten; 3735 * vec4 chichi; 3736 * }; 3737 * 3738 * Inspect program to check if Goku stride is 128 units. 3739 * 3740 * Test all shader stages. 3741 **/ 3742 class XFBBlockStrideTest : public TestBase 3743 { 3744 public: 3745 /* Public methods */ 3746 XFBBlockStrideTest(deqp::Context &context); 3747 ~XFBBlockStrideTest()3748 virtual ~XFBBlockStrideTest() 3749 { 3750 } 3751 3752 protected: 3753 /* Methods to be implemented by child class */ 3754 virtual std::string getTestCaseName(glw::GLuint test_case_index); 3755 virtual glw::GLuint getTestCaseNumber(); 3756 virtual bool testCase(glw::GLuint test_case_index); 3757 virtual void testInit(); 3758 3759 private: 3760 /* Private methods */ 3761 std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 3762 3763 bool inspectProgram(Utils::Program &program); 3764 3765 /* Private fields */ 3766 std::vector<Utils::Shader::STAGES> m_test_cases; 3767 }; 3768 3769 /** Implementation of test XFBBlockMemberStride. Description follows: 3770 * 3771 * Test verifies that xfb_stride qualifier change stride of output block 3772 * member. 3773 * 3774 * This test implements Buffer algorithm. Rasterization can be discarded. Test 3775 * following code snippet: 3776 * 3777 * layout (xfb_offset = 0) out Goku { 3778 * vec4 gohan; 3779 * layout (xfb_stride = 32) vec4 goten; 3780 * vec4 chichi; 3781 * }; 3782 * 3783 * gohan = EXPECTED_VALUE; 3784 * goten = EXPECTED_VALUE; 3785 * chichi = EXPECTED_VALUE; 3786 * 3787 * Test pass if: 3788 * - goten stride is reported as 32, 3789 * - chichi offset is reported as 48, 3790 * - values captured for all members match expected values, 3791 * - part of memory reserved for goten, that is not used, is not modified. 3792 **/ 3793 class XFBBlockMemberStrideTest : public BufferTestBase 3794 { 3795 public: 3796 XFBBlockMemberStrideTest(deqp::Context &context); ~XFBBlockMemberStrideTest()3797 ~XFBBlockMemberStrideTest() 3798 { 3799 } 3800 3801 protected: 3802 /* Protected methods */ 3803 virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector &out_descriptors); 3804 3805 virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string &out_assignments, 3806 std::string &out_calculations); 3807 3808 virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage, 3809 std::string &out_interface); 3810 3811 virtual bool inspectProgram(glw::GLuint test_case_index, Utils::Program &program, std::stringstream &out_stream); 3812 }; 3813 3814 /** Implementation of test XFBDuplicatedStride. Description follows: 3815 * 3816 * Test verifies that conflicting xfb_stride qualifiers cause build process 3817 * failure. 3818 * 3819 * Test following code snippets: 3820 * 3821 * layout (xfb_buffer = 0, xfb_stride = 64) out; 3822 * layout (xfb_buffer = 0, xfb_stride = 64) out; 3823 * 3824 * and 3825 * 3826 * layout (xfb_buffer = 0, xfb_stride = 64) out; 3827 * layout (xfb_buffer = 0, xfb_stride = 128) out; 3828 * 3829 * It is expected that: 3830 * - first snippet will build successfully, 3831 * - second snippet will fail to build. 3832 **/ 3833 class XFBDuplicatedStrideTest : public NegativeTestBase 3834 { 3835 public: 3836 /* Public methods */ 3837 XFBDuplicatedStrideTest(deqp::Context &context); 3838 ~XFBDuplicatedStrideTest()3839 virtual ~XFBDuplicatedStrideTest() 3840 { 3841 } 3842 3843 protected: 3844 /* Methods to be implemented by child class */ 3845 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 3846 3847 virtual std::string getTestCaseName(glw::GLuint test_case_index); 3848 virtual glw::GLuint getTestCaseNumber(); 3849 virtual bool isComputeRelevant(glw::GLuint test_case_index); 3850 virtual bool isFailureExpected(glw::GLuint test_case_index); 3851 virtual void testInit(); 3852 3853 private: 3854 enum CASES 3855 { 3856 VALID = 0, 3857 INVALID, 3858 3859 /* */ 3860 CASE_MAX 3861 }; 3862 3863 /* Private types */ 3864 struct testCase 3865 { 3866 CASES m_case; 3867 Utils::Shader::STAGES m_stage; 3868 }; 3869 3870 /* Private fields */ 3871 std::vector<testCase> m_test_cases; 3872 }; 3873 3874 /** Implementation of test XFBGetProgramResourceAPI. Description follows: 3875 * 3876 * Test verifies that GetProgramResource* API work as expected for transform 3877 * feedback. 3878 * 3879 * Test results of following queries: 3880 * - OFFSET, 3881 * - TRANSFORM_FEEDBACK_BUFFER_INDEX, 3882 * - TRANSFORM_FEEDBACK_BUFFER_STRIDE, 3883 * - TYPE. 3884 * 3885 * Test following cases: 3886 * - captured varyings are declared with API, TransformFeedbackVaryings 3887 * with INTERLEAVED_ATTRIBS, 3888 * - captured varyings are declared with API, TransformFeedbackVaryings 3889 * with SEPARATE_ATTRIBS, 3890 * - captured varyings are declared with "xfb" qualifiers. 3891 * 3892 * Following layout should be used in cases of INTERLEAVED_ATTRIBS and "xfb" 3893 * qualifiers: 3894 * | var 0 | var 1 | var 2 | var 3 3895 * buffer 0 | used | used | empty | used 3896 * buffer 1 | empty | used | empty | empty 3897 * 3898 * In "xfb" qualifiers case, use following snippet: 3899 * 3900 * layout (xfb_buffer = 1, xfb_stride = 4 * sizeof(type)) out; 3901 * 3902 * Declaration in shader should use following order: 3903 * buffer_0_var_1 3904 * buffer_1_var_1 3905 * buffer_0_var_3 3906 * buffer_0_var_0 3907 * 3908 * To make sure that captured varyings are active, they should be assigned. 3909 * 3910 * Test all types. Test all shader stages. 3911 **/ 3912 class XFBGetProgramResourceAPITest : public TestBase 3913 { 3914 public: 3915 /* Public methods */ 3916 XFBGetProgramResourceAPITest(deqp::Context &context); 3917 ~XFBGetProgramResourceAPITest()3918 virtual ~XFBGetProgramResourceAPITest() 3919 { 3920 } 3921 3922 protected: 3923 /* Methods to be implemented by child class */ 3924 virtual std::string getTestCaseName(glw::GLuint test_case_index); 3925 virtual glw::GLuint getTestCaseNumber(); 3926 virtual bool testCase(glw::GLuint test_case_index); 3927 virtual void testInit(); 3928 virtual void insertSkipComponents(int num_components, Utils::Program::NameVector &varyings); 3929 3930 private: 3931 /* Private enums */ 3932 enum CASES 3933 { 3934 INTERLEAVED, 3935 SEPARATED, 3936 XFB, 3937 }; 3938 3939 /* Private types */ 3940 struct test_Case 3941 { 3942 CASES m_case; 3943 Utils::Shader::STAGES m_stage; 3944 Utils::Type m_type; 3945 }; 3946 3947 /* Private methods */ 3948 std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 3949 3950 bool inspectProgram(glw::GLuint test_case_index, Utils::Program &program); 3951 3952 /* Private fields */ 3953 std::vector<test_Case> m_test_cases; 3954 }; 3955 3956 /** Implementation of test XFBOverrideQualifiersWithAPI. Description follows: 3957 * 3958 * Test verifies that API is ignored, when qualifiers are in use. 3959 * 3960 * This test follows Buffer algorithm. Rasterization can disabled. Test 3961 * following code snippet: 3962 * 3963 * layout (xfb_offset = 2 * sizeof(type)) out type vegeta; 3964 * out type trunks; 3965 * layout (xfb_offset = 0) out type goku; 3966 * out type gohan; 3967 * 3968 * vegeta = EXPECTED_VALUE; 3969 * trunks = EXPECTED_VALUE; 3970 * goku = EXPECTED_VALUE; 3971 * gohan = EXPECTED_VALUE; 3972 * 3973 * Use API, TransformFeedbackVaryings, to specify trunks and gohan as outputs 3974 * to be captured. 3975 * 3976 * Test pass if: 3977 * - correct values are captured for vegeta and goku, 3978 * - trunks and gohan are not captured, 3979 * - correct stride is reported. 3980 * 3981 * Test all types. Test all shader stages. 3982 **/ 3983 class XFBOverrideQualifiersWithAPITest : public BufferTestBase 3984 { 3985 public: 3986 XFBOverrideQualifiersWithAPITest(deqp::Context &context); 3987 ~XFBOverrideQualifiersWithAPITest()3988 ~XFBOverrideQualifiersWithAPITest() 3989 { 3990 } 3991 3992 protected: 3993 /* Protected methods */ 3994 virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector &out_descriptors); 3995 3996 virtual void getCapturedVaryings(glw::GLuint test_case_index, Utils::Program::NameVector &captured_varyings, 3997 glw::GLint *xfb_components); 3998 3999 virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string &out_assignments, 4000 std::string &out_calculations); 4001 4002 virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage, 4003 std::string &out_interface); 4004 4005 virtual std::string getTestCaseName(glw::GLuint test_case_index); 4006 virtual glw::GLuint getTestCaseNumber(); 4007 4008 virtual bool inspectProgram(glw::GLuint test_case_index, Utils::Program &program, std::stringstream &out_stream); 4009 }; 4010 4011 /** Implementation of test XFBVertexStreams. Description follows: 4012 * 4013 * Test verifies that "xfb" qualifiers work as expected with multiple output 4014 * streams. 4015 * 4016 * Test implements Buffer algorithm. Rasterization can be discarded. 4017 * 4018 * Test following code snippet: 4019 * 4020 * layout (xfb_buffer = 1, xfb_stride = 64) out; 4021 * layout (xfb_buffer = 2, xfb_stride = 64) out; 4022 * layout (xfb_buffer = 3, xfb_stride = 64) out; 4023 * 4024 * layout (stream = 0, xfb_buffer = 1, xfb_offset = 48) out vec4 goku; 4025 * layout (stream = 0, xfb_buffer = 1, xfb_offset = 32) out vec4 gohan; 4026 * layout (stream = 0, xfb_buffer = 1, xfb_offset = 16) out vec4 goten; 4027 * layout (stream = 1, xfb_buffer = 3, xfb_offset = 48) out vec4 picolo; 4028 * layout (stream = 1, xfb_buffer = 3, xfb_offset = 32) out vec4 vegeta; 4029 * layout (stream = 2, xfb_buffer = 2, xfb_offset = 32) out vec4 bulma; 4030 * 4031 * goku = EXPECTED_VALUE; 4032 * gohan = EXPECTED_VALUE; 4033 * goten = EXPECTED_VALUE; 4034 * picolo = EXPECTED_VALUE; 4035 * vegeta = EXPECTED_VALUE; 4036 * bulma = EXPECTED_VALUE; 4037 * 4038 * Test pass if all captured outputs have expected values. 4039 **/ 4040 class XFBVertexStreamsTest : public BufferTestBase 4041 { 4042 public: 4043 XFBVertexStreamsTest(deqp::Context &context); 4044 ~XFBVertexStreamsTest()4045 ~XFBVertexStreamsTest() 4046 { 4047 } 4048 4049 protected: 4050 /* Protected methods */ 4051 virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector &out_descriptors); 4052 4053 virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string &out_assignments, 4054 std::string &out_calculations); 4055 4056 virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage, 4057 std::string &out_interface); 4058 }; 4059 4060 /** Implementation of test XFBMultipleVertexStreams. Description follows: 4061 * 4062 * Test verifies that outputs from single stream must be captured with single 4063 * xfb binding. 4064 * 4065 * Test following code snippet: 4066 * 4067 * layout (xfb_buffer = 1, xfb_stride = 64) out; 4068 * layout (xfb_buffer = 3, xfb_stride = 64) out; 4069 * 4070 * layout (stream = 0, xfb_buffer = 1, xfb_offset = 48) out vec4 goku; 4071 * layout (stream = 1, xfb_buffer = 1, xfb_offset = 32) out vec4 gohan; 4072 * layout (stream = 2, xfb_buffer = 1, xfb_offset = 16) out vec4 goten; 4073 * 4074 * It is expected that linking of program will fail. 4075 **/ 4076 class XFBMultipleVertexStreamsTest : public NegativeTestBase 4077 { 4078 public: 4079 /* Public methods */ 4080 XFBMultipleVertexStreamsTest(deqp::Context &context); 4081 ~XFBMultipleVertexStreamsTest()4082 virtual ~XFBMultipleVertexStreamsTest() 4083 { 4084 } 4085 4086 protected: 4087 /* Methods to be implemented by child class */ 4088 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 4089 4090 virtual bool isComputeRelevant(glw::GLuint test_case_index); 4091 }; 4092 4093 /** Implementation of test XFBExceedBufferLimit. Description follows: 4094 * 4095 * Test verifies that MAX_TRANSFORM_FEEDBACK_BUFFERS limit is respected. 4096 * 4097 * Test following code snippets: 4098 * 4099 * layout (xfb_buffer = MAX_TRANSFORM_FEEDBACK_BUFFERS) out; 4100 * 4101 * , 4102 * 4103 * layout (xfb_buffer = MAX_TRANSFORM_FEEDBACK_BUFFERS) out vec4 output; 4104 * 4105 * and 4106 * 4107 * layout (xfb_buffer = MAX_TRANSFORM_FEEDBACK_BUFFERS) out Block { 4108 * vec4 member; 4109 * }; 4110 * 4111 * It is expected that build process will fail. 4112 * 4113 * Test all shader stages. 4114 **/ 4115 class XFBExceedBufferLimitTest : public NegativeTestBase 4116 { 4117 public: 4118 /* Public methods */ 4119 XFBExceedBufferLimitTest(deqp::Context &context); ~XFBExceedBufferLimitTest()4120 virtual ~XFBExceedBufferLimitTest() 4121 { 4122 } 4123 4124 protected: 4125 /* Methods to be implemented by child class */ 4126 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 4127 4128 virtual std::string getTestCaseName(glw::GLuint test_case_index); 4129 virtual glw::GLuint getTestCaseNumber(); 4130 virtual bool isComputeRelevant(glw::GLuint test_case_index); 4131 virtual void testInit(); 4132 4133 private: 4134 enum CASES 4135 { 4136 BLOCK = 0, 4137 GLOBAL, 4138 VECTOR, 4139 4140 /* */ 4141 CASE_MAX 4142 }; 4143 4144 /* Private types */ 4145 struct testCase 4146 { 4147 CASES m_case; 4148 Utils::Shader::STAGES m_stage; 4149 }; 4150 4151 /* Private fields */ 4152 std::vector<testCase> m_test_cases; 4153 }; 4154 4155 /** Implementation of test XFBExceedOffsetLimit. Description follows: 4156 * 4157 * Test verifies that MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS limit is 4158 * respected. 4159 * 4160 * Test following code snippets: 4161 * 4162 * layout (xfb_buffer = 0, xfb_stride = MAX_SIZE + 16) out; 4163 * 4164 * , 4165 * 4166 * layout (xfb_buffer = 0, xfb_offset = MAX_SIZE + 16) out vec4 output; 4167 * 4168 * and 4169 * 4170 * layout (xfb_buffer = 0, xfb_offset = MAX_SIZE + 16) out Block 4171 * { 4172 * vec4 member; 4173 * }; 4174 * 4175 * where MAX_SIZE is the maximum supported size of transform feedback buffer, 4176 * which should be equal to: 4177 * 4178 * MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS * sizeof(float) 4179 * 4180 * It is expected that build process will fail. 4181 * 4182 * Test all shader stages. 4183 **/ 4184 class XFBExceedOffsetLimitTest : public NegativeTestBase 4185 { 4186 public: 4187 /* Public methods */ 4188 XFBExceedOffsetLimitTest(deqp::Context &context); ~XFBExceedOffsetLimitTest()4189 virtual ~XFBExceedOffsetLimitTest() 4190 { 4191 } 4192 4193 protected: 4194 /* Methods to be implemented by child class */ 4195 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 4196 4197 virtual std::string getTestCaseName(glw::GLuint test_case_index); 4198 virtual glw::GLuint getTestCaseNumber(); 4199 virtual bool isComputeRelevant(glw::GLuint test_case_index); 4200 virtual void testInit(); 4201 4202 private: 4203 enum CASES 4204 { 4205 BLOCK = 0, 4206 GLOBAL, 4207 VECTOR, 4208 4209 /* */ 4210 CASE_MAX 4211 }; 4212 4213 /* Private types */ 4214 struct testCase 4215 { 4216 CASES m_case; 4217 Utils::Shader::STAGES m_stage; 4218 }; 4219 4220 /* Private fields */ 4221 std::vector<testCase> m_test_cases; 4222 }; 4223 4224 /** Implementation of test XFBGlobalBuffer. Description follows: 4225 * 4226 * Test verifies that global setting of xfb_buffer qualifier work as expected. 4227 * 4228 * This test implements Buffer algorithm. Rasterization can be discarded. Test 4229 * following code snippet: 4230 * 4231 * layout (xfb_buffer = 3) out; 4232 * 4233 * layout ( xfb_offset = 2 * sizeof(type)) out type chichi; 4234 * layout (xfb_buffer = 1, xfb_offset = 0) out type bulma; 4235 * layout (xfb_buffer = 1, xfb_offset = sizeof(type)) out Vegeta { 4236 * type trunks; 4237 * type bra; 4238 * }; 4239 * layout ( xfb_offset = 0) out Goku { 4240 * type gohan; 4241 * type goten; 4242 * }; 4243 * 4244 * chichi = EXPECTED_VALUE; 4245 * bulma = EXPECTED_VALUE; 4246 * trunks = EXPECTED_VALUE; 4247 * bra = EXPECTED_VALUE; 4248 * gohan = EXPECTED_VALUE; 4249 * goten = EXPECTED_VALUE; 4250 * 4251 * Test pass if all captured outputs have expected values. 4252 * 4253 * Test all shader stages. Test all types. 4254 **/ 4255 class XFBGlobalBufferTest : public BufferTestBase 4256 { 4257 public: 4258 XFBGlobalBufferTest(deqp::Context &context); 4259 ~XFBGlobalBufferTest()4260 ~XFBGlobalBufferTest() 4261 { 4262 } 4263 4264 protected: 4265 /* Protected methods */ 4266 virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector &out_descriptors); 4267 4268 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 4269 4270 virtual std::string getTestCaseName(glw::GLuint test_case_index); 4271 virtual glw::GLuint getTestCaseNumber(); 4272 virtual void testInit(); 4273 4274 private: 4275 /* Private types */ 4276 struct _testCase 4277 { 4278 Utils::Shader::STAGES m_stage; 4279 Utils::Type m_type; 4280 }; 4281 4282 /* Private fields */ 4283 std::vector<_testCase> m_test_cases; 4284 }; 4285 4286 /** Implementation of test XFBStride. Description follows: 4287 * 4288 * Test verifies that expected stride values are used. 4289 * 4290 * Test following code snippet: 4291 * 4292 * layout (xfb_offset = 0) out type output; 4293 * 4294 * output = EXPECTED_VALUE; 4295 * 4296 * Test all types. Test all shader stages. 4297 **/ 4298 class XFBStrideTest : public BufferTestBase 4299 { 4300 public: 4301 XFBStrideTest(deqp::Context &context); ~XFBStrideTest()4302 ~XFBStrideTest() 4303 { 4304 } 4305 4306 protected: 4307 /* Protected methods */ 4308 using BufferTestBase::executeDrawCall; 4309 4310 virtual bool executeDrawCall(bool tesEnabled, glw::GLuint test_case_index); 4311 virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector &out_descriptors); 4312 4313 virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string &out_assignments, 4314 std::string &out_calculations); 4315 4316 virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage, 4317 std::string &out_interface); 4318 4319 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 4320 4321 virtual std::string getTestCaseName(glw::GLuint test_case_index); 4322 virtual glw::GLuint getTestCaseNumber(); 4323 virtual void testInit(); 4324 4325 private: 4326 /* Private types */ 4327 struct testCase 4328 { 4329 Utils::Shader::STAGES m_stage; 4330 Utils::Type m_type; 4331 }; 4332 4333 /* Private fields */ 4334 std::vector<testCase> m_test_cases; 4335 }; 4336 4337 /** Implementation of test XFBBlockMemberBuffer. Description follows: 4338 * 4339 * Test verifies that member of block have to use same buffer as block. 4340 * 4341 * Test following code snippet: 4342 * 4343 * layout (xfb_offset = 0) out Goku 4344 * { 4345 * vec4 gohan; 4346 * layout (xfb_buffer = 1) vec4 goten; 4347 * }; 4348 * 4349 * It is expected that compilation will fail. 4350 * 4351 * Test all shader stages. 4352 **/ 4353 class XFBBlockMemberBufferTest : public NegativeTestBase 4354 { 4355 public: 4356 /* Public methods */ 4357 XFBBlockMemberBufferTest(deqp::Context &context); 4358 ~XFBBlockMemberBufferTest()4359 virtual ~XFBBlockMemberBufferTest() 4360 { 4361 } 4362 4363 protected: 4364 /* Methods to be implemented by child class */ 4365 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 4366 4367 virtual std::string getTestCaseName(glw::GLuint test_case_index); 4368 virtual glw::GLuint getTestCaseNumber(); 4369 virtual bool isComputeRelevant(glw::GLuint test_case_index); 4370 virtual void testInit(); 4371 4372 private: 4373 /* Private types */ 4374 struct testCase 4375 { 4376 Utils::Shader::STAGES m_stage; 4377 }; 4378 4379 /* Private fields */ 4380 std::vector<testCase> m_test_cases; 4381 }; 4382 4383 /** Implementation of test XFBOutputOverlapping. Description follows: 4384 * 4385 * Test verifies that overlapped outputs are reported as errors by compiler. 4386 * 4387 * Test following code snippet: 4388 * 4389 * layout (xfb_offset = 0) out type gohan; 4390 * layout (xfb_offset = 0.5 * sizeof(type)) out type goten; 4391 * 4392 * gohan = EXPECTED_VALUE; 4393 * goten = EXPECTED_VALUE; 4394 * 4395 * It is expected that compilation will fail. 4396 * 4397 * Test all shader stages. Test all types. 4398 **/ 4399 class XFBOutputOverlappingTest : public NegativeTestBase 4400 { 4401 public: 4402 /* Public methods */ 4403 XFBOutputOverlappingTest(deqp::Context &context); 4404 ~XFBOutputOverlappingTest()4405 virtual ~XFBOutputOverlappingTest() 4406 { 4407 } 4408 4409 protected: 4410 /* Methods to be implemented by child class */ 4411 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 4412 4413 virtual std::string getTestCaseName(glw::GLuint test_case_index); 4414 virtual glw::GLuint getTestCaseNumber(); 4415 virtual bool isComputeRelevant(glw::GLuint test_case_index); 4416 virtual void testInit(); 4417 4418 private: 4419 /* Private types */ 4420 struct testCase 4421 { 4422 glw::GLuint m_offset; 4423 Utils::Shader::STAGES m_stage; 4424 Utils::Type m_type; 4425 }; 4426 4427 /* Private fields */ 4428 std::vector<testCase> m_test_cases; 4429 }; 4430 4431 /** Implementation of test XFBInvalidOffsetAlignment. Description follows: 4432 * 4433 * Test verifies that invalidly aligned outputs cause a failure to build 4434 * process. 4435 * 4436 * Test following code snippet: 4437 * 4438 * layout (xfb_offset = OFFSET) out type goku; 4439 * 4440 * goku = EXPECTED_VALUE; 4441 * 4442 * Select OFFSET values so as to cause invalid alignment. Inspect program to 4443 * verify offset of goku. 4444 * 4445 * Test all shader stages. Test all types. Test all offsets in range: 4446 * (sizeof(type), 2 * sizeof(type)). 4447 **/ 4448 class XFBInvalidOffsetAlignmentTest : public NegativeTestBase 4449 { 4450 public: 4451 /* Public methods */ 4452 XFBInvalidOffsetAlignmentTest(deqp::Context &context); 4453 ~XFBInvalidOffsetAlignmentTest()4454 virtual ~XFBInvalidOffsetAlignmentTest() 4455 { 4456 } 4457 4458 protected: 4459 /* Methods to be implemented by child class */ 4460 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 4461 4462 virtual std::string getTestCaseName(glw::GLuint test_case_index); 4463 virtual glw::GLuint getTestCaseNumber(); 4464 virtual bool isComputeRelevant(glw::GLuint test_case_index); 4465 virtual void testInit(); 4466 4467 private: 4468 /* Private types */ 4469 struct testCase 4470 { 4471 glw::GLuint m_offset; 4472 Utils::Shader::STAGES m_stage; 4473 Utils::Type m_type; 4474 }; 4475 4476 /* Private fields */ 4477 std::vector<testCase> m_test_cases; 4478 }; 4479 4480 /** Implementation of test XFBCaptureInactiveOutputVariable. Description follows: 4481 * 4482 * Test verifies behavior of inactive outputs. 4483 * 4484 * This test implements Buffer algorithm. Rasterization can be disabled. Draw 4485 * two vertices instead of one. Test following code snippet: 4486 * 4487 * layout (xfb_offset = 16) out vec4 goku; 4488 * layout (xfb_offset = 32) out vec4 gohan; 4489 * layout (xfb_offset = 0) out vec4 goten; 4490 * 4491 * gohan = EXPECTED_VALUE; 4492 * goten = EXPECTED_VALUE; 4493 * 4494 * Test pass if: 4495 * - values captured for goten and gohan are as expected, 4496 * - goku value is undefined 4497 * - stride is 3 * sizeof(vec4) - 48 4498 * 4499 * Test all shader stages. 4500 **/ 4501 class XFBCaptureInactiveOutputVariableTest : public BufferTestBase 4502 { 4503 public: 4504 XFBCaptureInactiveOutputVariableTest(deqp::Context &context); ~XFBCaptureInactiveOutputVariableTest()4505 ~XFBCaptureInactiveOutputVariableTest() 4506 { 4507 } 4508 4509 protected: 4510 /* Protected methods */ 4511 using BufferTestBase::executeDrawCall; 4512 virtual bool executeDrawCall(bool tesEnabled, glw::GLuint test_case_index); 4513 virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector &out_descriptors); 4514 4515 virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string &out_assignments, 4516 std::string &out_calculations); 4517 4518 virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage, 4519 std::string &out_interface); 4520 4521 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 4522 4523 virtual std::string getTestCaseName(glw::GLuint test_case_index); 4524 virtual glw::GLuint getTestCaseNumber(); 4525 4526 virtual bool inspectProgram(glw::GLuint test_case_index, Utils::Program &program, std::stringstream &out_stream); 4527 4528 virtual bool verifyBuffers(bufferCollection &buffers); 4529 4530 private: 4531 enum test_cases 4532 { 4533 TEST_VS = 0, 4534 TEST_TES, 4535 TEST_GS, 4536 4537 /* */ 4538 TEST_MAX 4539 }; 4540 }; 4541 4542 /** Implementation of test XFBCaptureInactiveOutputComponent. Description follows: 4543 * 4544 * Test verifies behavior of inactive component. 4545 * 4546 * This test implements Buffer algorithm. Rasterization can be disabled. Draw 4547 * two vertices instead of one. Test following code snippet: 4548 * 4549 * layout (xfb_offset = 32) out vec4 goku; 4550 * layout (xfb_offset = 0) out vec4 gohan; 4551 * layout (xfb_offset = 16) out vec4 goten; 4552 * layout (xfb_offset = 48) out vec4 chichi; 4553 * layout (xfb_offset = 112) out vec4 vegeta; 4554 * layout (xfb_offset = 96) out vec4 trunks; 4555 * layout (xfb_offset = 80) out vec4 bra; 4556 * layout (xfb_offset = 64) out vec4 bulma; 4557 * 4558 * goku.x = EXPECTED_VALUE; 4559 * goku.z = EXPECTED_VALUE; 4560 * gohan.y = EXPECTED_VALUE; 4561 * gohan.w = EXPECTED_VALUE; 4562 * goten.x = EXPECTED_VALUE; 4563 * goten.y = EXPECTED_VALUE; 4564 * chichi.z = EXPECTED_VALUE; 4565 * chichi.w = EXPECTED_VALUE; 4566 * vegeta.x = EXPECTED_VALUE; 4567 * trunks.y = EXPECTED_VALUE; 4568 * bra.z = EXPECTED_VALUE; 4569 * bulma.w = EXPECTED_VALUE; 4570 * 4571 * Test pass when captured values of all assigned components match expected 4572 * values, while not assigned ones are undefined. 4573 * 4574 * Test all shader stages. 4575 **/ 4576 class XFBCaptureInactiveOutputComponentTest : public BufferTestBase 4577 { 4578 public: 4579 XFBCaptureInactiveOutputComponentTest(deqp::Context &context); ~XFBCaptureInactiveOutputComponentTest()4580 ~XFBCaptureInactiveOutputComponentTest() 4581 { 4582 } 4583 4584 protected: 4585 /* Protected methods */ 4586 using BufferTestBase::executeDrawCall; 4587 virtual bool executeDrawCall(bool tesEnabled, glw::GLuint test_case_index); 4588 4589 virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector &out_descriptors); 4590 4591 virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string &out_assignments, 4592 std::string &out_calculations); 4593 4594 virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage, 4595 std::string &out_interface); 4596 4597 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 4598 4599 virtual std::string getTestCaseName(glw::GLuint test_case_index); 4600 virtual glw::GLuint getTestCaseNumber(); 4601 virtual bool verifyBuffers(bufferCollection &buffers); 4602 4603 private: 4604 enum test_cases 4605 { 4606 TEST_VS = 0, 4607 TEST_TES, 4608 TEST_GS, 4609 4610 /* */ 4611 TEST_MAX 4612 }; 4613 }; 4614 4615 /** Implementation of test XFBCaptureInactiveOutputBlockMember. Description follows: 4616 * 4617 * Test verifies behaviour of inactive block member. 4618 * 4619 * This test implements Buffer algorithm. Rasterization can be disabled. Draw 4620 * two vertices instead of one. Test following code snippet: 4621 * 4622 * layout (xfb_offset = 16) out Goku { 4623 * vec4 gohan; 4624 * vec4 goten; 4625 * vec4 chichi; 4626 * }; 4627 * 4628 * gohan = EXPECTED_VALUE; 4629 * chichi = EXPECTED_VALUE; 4630 * 4631 * Test pass when captured values of gohan and chichi match expected values. 4632 * It is expected that goten will receive undefined value. 4633 * 4634 * Test all shader stages. 4635 **/ 4636 class XFBCaptureInactiveOutputBlockMemberTest : public BufferTestBase 4637 { 4638 public: 4639 XFBCaptureInactiveOutputBlockMemberTest(deqp::Context &context); 4640 ~XFBCaptureInactiveOutputBlockMemberTest()4641 ~XFBCaptureInactiveOutputBlockMemberTest() 4642 { 4643 } 4644 4645 protected: 4646 /* Protected methods */ 4647 using BufferTestBase::executeDrawCall; 4648 virtual bool executeDrawCall(bool tesEnabled, glw::GLuint test_case_index); 4649 virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector &out_descriptors); 4650 4651 virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string &out_assignments, 4652 std::string &out_calculations); 4653 4654 virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage, 4655 std::string &out_interface); 4656 4657 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 4658 4659 virtual std::string getTestCaseName(glw::GLuint test_case_index); 4660 virtual glw::GLuint getTestCaseNumber(); 4661 virtual bool verifyBuffers(bufferCollection &buffers); 4662 4663 private: 4664 enum test_cases 4665 { 4666 TEST_VS = 0, 4667 TEST_TES, 4668 TEST_GS, 4669 4670 /* */ 4671 TEST_MAX 4672 }; 4673 }; 4674 4675 /** Implementation of test XFBCaptureStruct. Description follows: 4676 * 4677 * Test verifies that structures are captured as expected. 4678 * 4679 * This test implements Buffer algorithm. Rasterization can be disabled. Draw 4680 * two vertices instead of one. Test following code snippet: 4681 * 4682 * struct Goku { 4683 * vec4 gohan; 4684 * vec4 goten; 4685 * vec4 chichi; 4686 * }; 4687 * 4688 * layout (xfb_offset = 16) out Goku goku; 4689 * 4690 * goku.gohan = EXPECTED_VALUE; 4691 * goku.chichi = EXPECTED_VALUE; 4692 * 4693 * Test pass when captured values of gohan and chichi match expected values. 4694 * It is expected that goten will receive undefined value. 4695 * 4696 * Test all shader stages. 4697 **/ 4698 class XFBCaptureStructTest : public BufferTestBase 4699 { 4700 public: 4701 XFBCaptureStructTest(deqp::Context &context); 4702 ~XFBCaptureStructTest()4703 ~XFBCaptureStructTest() 4704 { 4705 } 4706 4707 protected: 4708 /* Protected methods */ 4709 using BufferTestBase::executeDrawCall; 4710 virtual bool executeDrawCall(bool tesEnabled, glw::GLuint test_case_index); 4711 4712 virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector &out_descriptors); 4713 4714 virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string &out_assignments, 4715 std::string &out_calculations); 4716 4717 virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage, 4718 std::string &out_interface); 4719 4720 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 4721 4722 virtual std::string getTestCaseName(glw::GLuint test_case_index); 4723 virtual glw::GLuint getTestCaseNumber(); 4724 virtual bool verifyBuffers(bufferCollection &buffers); 4725 4726 private: 4727 enum test_cases 4728 { 4729 TEST_VS = 0, 4730 TEST_TES, 4731 TEST_GS, 4732 4733 /* */ 4734 TEST_MAX 4735 }; 4736 }; 4737 4738 /** Implementation of test XFBCaptureUnsizedArray. Description follows: 4739 * 4740 * Test verifies this is not allowed to qualify unsized array with "xfb". 4741 * 4742 * Test following code snippet: 4743 * 4744 * layout (xfb_offset = 0) out vec4 goku[]; 4745 * 4746 * goku[0] = EXPECTED_VALUE; 4747 * 4748 * It is expected that compilation will fail. 4749 * 4750 * Test all shader stages. 4751 **/ 4752 class XFBCaptureUnsizedArrayTest : public NegativeTestBase 4753 { 4754 public: 4755 /* Public methods */ 4756 XFBCaptureUnsizedArrayTest(deqp::Context &context); ~XFBCaptureUnsizedArrayTest()4757 virtual ~XFBCaptureUnsizedArrayTest() 4758 { 4759 } 4760 4761 protected: 4762 /* Methods to be implemented by child class */ 4763 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 4764 4765 virtual std::string getTestCaseName(glw::GLuint test_case_index); 4766 virtual glw::GLuint getTestCaseNumber(); 4767 virtual bool isComputeRelevant(glw::GLuint test_case_index); 4768 virtual void testInit(); 4769 4770 private: 4771 /* Private types */ 4772 struct testCase 4773 { 4774 Utils::Shader::STAGES m_stage; 4775 }; 4776 4777 /* Private fields */ 4778 std::vector<testCase> m_test_cases; 4779 }; 4780 4781 /** Implementation of test XFBExplicitLocationTest. Description follows: 4782 * 4783 * Test verifies that explicit location on matrices and arrays does not impact xfb output. 4784 * 4785 * Test following code snippet: 4786 * 4787 * layout (location = 0, xfb_offset = 0) out vec2 goku[3]; 4788 * 4789 * Is expected to have the same output as: 4790 * 4791 * layout (xfb_offset = 0) out vec2 goku[3]; 4792 * 4793 * While explicit location does impact varyings layout of matrices and arrays, see 4794 * Ref. GLSL 4.60, Section 4.4.2. "Output Layout Qualifiers" - it shall not impact 4795 * xfb output. 4796 * 4797 * Test all shader stages. 4798 **/ 4799 class XFBExplicitLocationTest : public BufferTestBase 4800 { 4801 public: 4802 XFBExplicitLocationTest(deqp::Context &context); ~XFBExplicitLocationTest()4803 ~XFBExplicitLocationTest() 4804 { 4805 } 4806 4807 protected: 4808 /* Protected methods */ 4809 using BufferTestBase::executeDrawCall; 4810 4811 virtual bool executeDrawCall(bool tesEnabled, glw::GLuint test_case_index); 4812 virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector &out_descriptors); 4813 4814 virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string &out_assignments, 4815 std::string &out_calculations); 4816 4817 virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage, 4818 std::string &out_interface); 4819 4820 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 4821 4822 virtual std::string getTestCaseName(glw::GLuint test_case_index); 4823 virtual glw::GLuint getTestCaseNumber(); 4824 virtual void testInit(); 4825 4826 private: 4827 /* Private types */ 4828 struct testCase 4829 { 4830 Utils::Shader::STAGES m_stage; 4831 Utils::Type m_type; 4832 glw::GLuint m_array_size; 4833 }; 4834 4835 /* Private fields */ 4836 std::vector<testCase> m_test_cases; 4837 }; 4838 4839 /** Implementation of test XFBExplicitLocationStructTest. Description follows: 4840 * 4841 * Test verifies that explicit location on struct does not impact xfb output. 4842 * 4843 * Test following code snippet: 4844 * struct TestStruct { 4845 * float a; 4846 * double b; 4847 * }; 4848 * 4849 * layout (location = 0, xfb_offset = 0) flat out TestStruct goku; 4850 * 4851 * Is expected to have the same output as: 4852 * 4853 * layout (xfb_offset = 0) flat out TestStruct goku; 4854 * 4855 * While explicit location does impact varyings layout of structs, see 4856 * Ref. GLSL 4.60, Section 4.4.2. "Output Layout Qualifiers" - it shall not impact 4857 * xfb output. 4858 * 4859 * Test all shader stages. 4860 **/ 4861 class XFBExplicitLocationStructTest : public BufferTestBase 4862 { 4863 public: 4864 XFBExplicitLocationStructTest(deqp::Context &context); ~XFBExplicitLocationStructTest()4865 ~XFBExplicitLocationStructTest() 4866 { 4867 } 4868 4869 protected: 4870 /* Protected methods */ 4871 using BufferTestBase::executeDrawCall; 4872 4873 virtual bool executeDrawCall(bool tesEnabled, glw::GLuint test_case_index); 4874 virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector &out_descriptors); 4875 4876 virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string &out_assignments, 4877 std::string &out_calculations); 4878 4879 virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage, 4880 std::string &out_interface); 4881 4882 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 4883 4884 virtual std::string getTestCaseName(glw::GLuint test_case_index); 4885 virtual glw::GLuint getTestCaseNumber(); 4886 virtual void testInit(); 4887 4888 private: 4889 /* Private types */ 4890 4891 struct testType 4892 { 4893 Utils::Type m_type; 4894 glw::GLuint m_array_size; 4895 }; 4896 4897 struct testCase 4898 { 4899 Utils::Shader::STAGES m_stage; 4900 std::vector<testType> m_types; 4901 bool m_nested_struct; 4902 }; 4903 4904 /* Private fields */ 4905 std::vector<testCase> m_test_cases; 4906 }; 4907 4908 } // namespace EnhancedLayouts 4909 4910 /** Group class for Shader Language 420Pack conformance tests */ 4911 class EnhancedLayoutsTests : public deqp::TestCaseGroup 4912 { 4913 public: 4914 /* Public methods */ 4915 EnhancedLayoutsTests(deqp::Context &context); 4916 ~EnhancedLayoutsTests(void)4917 virtual ~EnhancedLayoutsTests(void) 4918 { 4919 } 4920 4921 virtual void init(void); 4922 4923 private: 4924 /* Private methods */ 4925 EnhancedLayoutsTests(const EnhancedLayoutsTests &other); 4926 EnhancedLayoutsTests &operator=(const EnhancedLayoutsTests &other); 4927 }; 4928 4929 } // namespace gl4cts 4930 4931 #endif // _GL4CENHANCEDLAYOUTSTESTS_HPP 4932