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