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