Fix emulated compressed format issues
[platform/upstream/VK-GL-CTS.git] / external / openglcts / modules / gl / gl4cDirectStateAccessTests.hpp
1 #ifndef _GL4CDIRECTSTATEACCESSTESTS_HPP
2 #define _GL4CDIRECTSTATEACCESSTESTS_HPP
3 /*-------------------------------------------------------------------------
4  * OpenGL Conformance Test Suite
5  * -----------------------------
6  *
7  * Copyright (c) 2015-2016 The Khronos Group Inc.
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  */ /*!
22  * \file
23  * \brief
24  */ /*-------------------------------------------------------------------*/
25
26 /**
27  */ /*!
28  * \file  gl4cDirectStateAccessTests.hpp
29  * \brief Conformance tests for the Direct State Access feature functionality.
30  */ /*-----------------------------------------------------------------------------*/
31
32 /* Includes. */
33
34 #include "glcTestCase.hpp"
35 #include "glwDefs.hpp"
36 #include "tcuDefs.hpp"
37
38 #include <string>
39 #include <typeinfo>
40
41 namespace gl4cts
42 {
43 namespace DirectStateAccess
44 {
45 /** @class Tests
46  *
47  *  @brief Direct State Access test group.
48  */
49 class Tests : public deqp::TestCaseGroup
50 {
51 public:
52         /* Public member functions */
53         Tests(deqp::Context& context);
54
55         void init();
56
57 private:
58         /* Private member functions */
59         Tests(const Tests& other);
60         Tests& operator=(const Tests& other);
61 };
62 /* Tests class */
63
64 /* Direct State Access Feature Interfaces */
65
66 /* Direct State Access Transform Feedback Tests */
67 namespace TransformFeedback
68 {
69 /** @class CreationTest
70  *
71  *  @brief Direct State Access Transform Feedback Creation test cases.
72  *
73  *  Test follows the steps:
74  *
75  *      Create at least two transform feedback objects names with
76  *      GenTransformFeedbacks function. Check them without binding, using
77  *      IsTransformFeedback function. Expect GL_FALSE.
78  *
79  *      Create at least two transform feedback objects with
80  *      CreateTransformFeedbacks function. Check them without binding, using
81  *      IsTransformFeedback function. Expect GL_TRUE.
82  *
83  *      Check that transform feedback binding point is unchanged.
84  */
85 class CreationTest : public deqp::TestCase
86 {
87 public:
88         /* Public member functions */
89         CreationTest(deqp::Context& context);
90
91         virtual tcu::TestNode::IterateResult iterate();
92
93 private:
94         /* Private member functions */
95         CreationTest(const CreationTest& other);
96         CreationTest& operator=(const CreationTest& other);
97 };
98 /* CreationTest class */
99
100 /** @class DefaultsTest
101  *
102  *  @brief Direct State Access Transform Feedback Default State test cases.
103  *
104  *  Test follows the steps:
105  *
106  *       Create transform feedback object with CreateTransformFeedbacks function.
107  *
108  *      Query parameters TRANSFORM_FEEDBACK_BUFFER_BINDING using
109  *      GetTransformFeedbacki_v for all available indexed binding points. For
110  *      all queries, expect value equal to 0.
111  *
112  *      Query parameters:
113  *       -  TRANSFORM_FEEDBACK_BUFFER_START and
114  *       -  TRANSFORM_FEEDBACK_BUFFER_SIZE
115  *      using GetTransformFeedbacki64_v for all available indexed binding
116  *      points. For all queries, expect value equal to 0.
117  *
118  *      Query parameters:
119  *       -  TRANSFORM_FEEDBACK_PAUSED and
120  *       -  TRANSFORM_FEEDBACK_ACTIVE
121  *      using GetTransformFeedbackiv. For all queries, expect value equal to
122  *      FALSE.
123  */
124 class DefaultsTest : public deqp::TestCase
125 {
126 public:
127         /* Public member functions */
128         DefaultsTest(deqp::Context& context);
129
130         virtual tcu::TestNode::IterateResult iterate();
131
132 private:
133         /* Private member functions */
134         DefaultsTest(const DefaultsTest& other);
135         DefaultsTest& operator=(const DefaultsTest& other);
136
137         /* Function pointers type definitions and declarations. */
138         typedef void(GLW_APIENTRY* GetTransformFeedbackiv_ProcAddress)(glw::GLuint xfb, glw::GLenum pname,
139                                                                                                                                    glw::GLint* param);
140         typedef void(GLW_APIENTRY* GetTransformFeedbacki_v_ProcAddress)(glw::GLuint xfb, glw::GLenum pname,
141                                                                                                                                         glw::GLuint index, glw::GLint* param);
142         typedef void(GLW_APIENTRY* GetTransformFeedbacki64_v_ProcAddress)(glw::GLuint xfb, glw::GLenum pname,
143                                                                                                                                           glw::GLuint index, glw::GLint64* param);
144
145         GetTransformFeedbackiv_ProcAddress      m_gl_getTransformFeedbackiv;
146         GetTransformFeedbacki_v_ProcAddress   m_gl_getTransformFeedbacki_v;
147         GetTransformFeedbacki64_v_ProcAddress m_gl_getTransformFeedbacki64_v;
148
149         /* Private member variables */
150         glw::GLuint m_xfb_dsa;
151         glw::GLint  m_xfb_indexed_binding_points_count;
152
153         /* Private member functions. */
154         void prepare();
155         bool testBuffersBindingPoints();
156         bool testBuffersDimensions();
157         bool testActive();
158         bool testPaused();
159         void clean();
160 };
161 /* DefaultsTest class */
162
163 /** @class BuffersTest
164  *
165  *  @brief Direct State Access Transform Feedback Buffer Objects binding test cases.
166  *         The test follows the steps:
167  *
168  *             Create transform feedback object with CreateTransformFeedbacks function.
169  *
170  *             Create two buffer objects using GenBuffers and BindBuffer functions.
171  *             Allocate storage for them using BufferData.
172  *
173  *             Bind the first buffer to transform feedback object indexed binding point
174  *             0 using TransformFeedbackBufferBase function.
175  *
176  *             Bind a first half of the second buffer to transform feedback object
177  *             indexed binding point 1 using TransformFeedbackBufferRange.
178  *
179  *             Bind a second half of the second buffer to transform feedback object
180  *             indexed binding point 12 using TransformFeedbackBufferRange.
181  *
182  *             Query parameter TRANSFORM_FEEDBACK_BUFFER_BINDING using
183  *             GetTransformFeedbacki_v for all 1st, 2nd and 3rd indexed binding point.
184  *             For all queries, expect value equal to the corresponding buffers'
185  *             identifiers.
186  *
187  *             Query parameters:
188  *              -  TRANSFORM_FEEDBACK_BUFFER_START and
189  *              -  TRANSFORM_FEEDBACK_BUFFER_SIZE
190  *             using GetTransformFeedbacki64_v for indexed binding points 0, 1 and 2.
191  *             Verify returned values.
192  */
193 class BuffersTest : public deqp::TestCase
194 {
195 public:
196         /* Public member functions */
197         BuffersTest(deqp::Context& context);
198
199         virtual tcu::TestNode::IterateResult iterate();
200
201 private:
202         /* Private member functions */
203         BuffersTest(const BuffersTest& other);
204         BuffersTest& operator=(const BuffersTest& other);
205
206         /* Function pointers type definitions and declarations. */
207         typedef void(GLW_APIENTRY* GetTransformFeedbacki_v_ProcAddress)(glw::GLuint xfb, glw::GLenum pname,
208                                                                                                                                         glw::GLuint index, glw::GLint* param);
209         typedef void(GLW_APIENTRY* GetTransformFeedbacki64_v_ProcAddress)(glw::GLuint xfb, glw::GLenum pname,
210                                                                                                                                           glw::GLuint index, glw::GLint64* param);
211         typedef void(GLW_APIENTRY* TransformFeedbackBufferBase_ProcAddress)(glw::GLuint xfb, glw::GLuint index,
212                                                                                                                                                 glw::GLuint buffer);
213         typedef void(GLW_APIENTRY* TransformFeedbackBufferRange_ProcAddress)(glw::GLuint xfb, glw::GLuint index,
214                                                                                                                                                  glw::GLuint buffer, glw::GLintptr offset,
215                                                                                                                                                  glw::GLsizei size);
216
217         GetTransformFeedbacki_v_ProcAddress              m_gl_getTransformFeedbacki_v;
218         GetTransformFeedbacki64_v_ProcAddress   m_gl_getTransformFeedbacki64_v;
219         TransformFeedbackBufferBase_ProcAddress  m_gl_TransformFeedbackBufferBase;
220         TransformFeedbackBufferRange_ProcAddress m_gl_TransformFeedbackBufferRange;
221
222         /* Private member variables */
223         glw::GLuint m_xfb_dsa;
224         glw::GLuint m_bo_a;
225         glw::GLuint m_bo_b;
226
227         /* Private static variables */
228         static const glw::GLuint s_bo_size;
229
230         /* Private member functions. */
231         void prepareObjects();
232         bool prepareTestSetup();
233         bool testBindingPoint(glw::GLuint const index, glw::GLint const expected_value,
234                                                   glw::GLchar const* const tested_function_name);
235         bool testStart(glw::GLuint const index, glw::GLint const expected_value,
236                                    glw::GLchar const* const tested_function_name);
237         bool testSize(glw::GLuint const index, glw::GLint const expected_value,
238                                   glw::GLchar const* const tested_function_name);
239         void clean();
240 };
241 /* BuffersTest class */
242
243 /** @class ErrorsTest
244  *
245  *  @brief Direct State Access Transform Feedback Negative test cases.
246  *         The test follows steps:
247  *
248  *              Check that CreateTransformFeedbacks generates INVALID_VALUE error if
249  *              number of transform feedback objects to create is negative.
250  *
251  *              Check that GetTransformFeedbackiv, GetTransformFeedbacki_v and
252  *              GetTransformFeedbacki64_v generate INVALID_OPERATION error if xfb is not
253  *              zero or the name of an existing transform feedback object.
254  *
255  *              Check that GetTransformFeedbackiv generates INVALID_ENUM error if pname
256  *              is not TRANSFORM_FEEDBACK_PAUSED or TRANSFORM_FEEDBACK_ACTIVE.
257  *
258  *              Check that GetTransformFeedbacki_v generates INVALID_ENUM error if pname
259  *              is not TRANSFORM_FEEDBACK_BUFFER_BINDING.
260  *
261  *              Check that GetTransformFeedbacki64_v generates INVALID_ENUM error if
262  *              pname is not TRANSFORM_FEEDBACK_BUFFER_START or
263  *              TRANSFORM_FEEDBACK_BUFFER_SIZE.
264  *
265  *              Check that GetTransformFeedbacki_v and GetTransformFeedbacki64_v
266  *              generate INVALID_VALUE error by GetTransformFeedbacki_v and
267  *              GetTransformFeedbacki64_v if index is greater than or equal to the
268  *              number of binding points for transform feedback (the value of
269  *              MAX_TRANSFORM_FEEDBACK_BUFFERS).
270  */
271 class ErrorsTest : public deqp::TestCase
272 {
273 public:
274         /* Public member functions */
275         ErrorsTest(deqp::Context& context);
276
277         virtual tcu::TestNode::IterateResult iterate();
278
279 private:
280         /* Private member functions */
281         ErrorsTest(const ErrorsTest& other);
282         ErrorsTest& operator=(const ErrorsTest& other);
283
284         /* Function pointers type definitions and declarations. */
285         typedef void(GLW_APIENTRY* GetTransformFeedbackiv_ProcAddress)(glw::GLuint xfb, glw::GLenum pname,
286                                                                                                                                    glw::GLint* param);
287         typedef void(GLW_APIENTRY* GetTransformFeedbacki_v_ProcAddress)(glw::GLuint xfb, glw::GLenum pname,
288                                                                                                                                         glw::GLuint index, glw::GLint* param);
289         typedef void(GLW_APIENTRY* GetTransformFeedbacki64_v_ProcAddress)(glw::GLuint xfb, glw::GLenum pname,
290                                                                                                                                           glw::GLuint index, glw::GLint64* param);
291
292         GetTransformFeedbackiv_ProcAddress      m_gl_getTransformFeedbackiv;
293         GetTransformFeedbacki_v_ProcAddress   m_gl_getTransformFeedbacki_v;
294         GetTransformFeedbacki64_v_ProcAddress m_gl_getTransformFeedbacki64_v;
295
296         /* Private member functions. */
297         void prepareFunctionPointers();
298         void cleanErrors();
299
300         bool testCreateTransformFeedbacksForInvalidNumberOfObjects();
301         bool testQueriesForInvalidNameOfObject();
302         bool testGetTransformFeedbackivQueryForInvalidParameterName();
303         bool testGetTransformFeedbacki_vQueryForInvalidParameterName();
304         bool testGetTransformFeedbacki64_vQueryForInvalidParameterName();
305         bool testIndexedQueriesForInvalidBindingPoint();
306 };
307 /* BuffersTest class */
308
309 /** @class FunctionalTest
310  *
311  *  @brief Direct State Access Transform Feedback Functional test cases.
312  *
313  *  @note  The test follows steps:
314  *
315  *             Create transform feedback object with CreateTransformFeedbacks function.
316  *
317  *             Create buffer object using GenBuffers and BindBuffer functions.
318  *             Allocate storage for it using BufferData.
319  *
320  *             Bind the buffer to transform feedback object indexed binding point 0
321  *             using TransformFeedbackBufferBase function.
322  *
323  *             Prepare program with vertex shader which outputs VertexID to transform
324  *             feedback varying.
325  *
326  *             Create and bind empty vertex array object.
327  *
328  *             Begin transform feedback environment.
329  *
330  *             Using the program with discarded rasterizer, draw array of 4 indices
331  *             using POINTS.
332  *
333  *             Pause transform feedback environment.
334  *
335  *             Query parameter TRANSFORM_FEEDBACK_PAUSED using GetTransformFeedbackiv.
336  *             Expect value equal to TRUE.
337  *
338  *             Query parameter TRANSFORM_FEEDBACK_PAUSED using GetTransformFeedbackiv.
339  *             Expect value equal to FALSE.
340  *
341  *             Resume transform feedback environment.
342  *
343  *             Query parameter TRANSFORM_FEEDBACK_PAUSED using GetTransformFeedbackiv.
344  *             Expect value equal to FALSE.
345  *
346  *             Query parameter TRANSFORM_FEEDBACK_PAUSED using GetTransformFeedbackiv.
347  *             Expect value equal to TRUE.
348  *
349  *             End Transform feedback environment.
350  *
351  *             Verify data in the buffer using MapBuffer function.
352  */
353 class FunctionalTest : public deqp::TestCase
354 {
355 public:
356         /* Public member functions */
357         FunctionalTest(deqp::Context& context);
358
359         virtual tcu::TestNode::IterateResult iterate();
360
361 private:
362         /* Private member functions */
363         FunctionalTest(const FunctionalTest& other);
364         FunctionalTest& operator=(const FunctionalTest& other);
365
366         /* Function pointers type definitions and declarations. */
367         typedef void(GLW_APIENTRY* GetTransformFeedbackiv_ProcAddress)(glw::GLuint xfb, glw::GLenum pname,
368                                                                                                                                    glw::GLint* param);
369         typedef void(GLW_APIENTRY* TransformFeedbackBufferBase_ProcAddress)(glw::GLuint xfb, glw::GLuint index,
370                                                                                                                                                 glw::GLuint buffer);
371
372         GetTransformFeedbackiv_ProcAddress              m_gl_getTransformFeedbackiv;
373         TransformFeedbackBufferBase_ProcAddress m_gl_TransformFeedbackBufferBase;
374
375         /* Private member variables. */
376         glw::GLuint m_xfb_dsa;
377         glw::GLuint m_bo;
378         glw::GLuint m_po;
379         glw::GLuint m_vao;
380
381         /* Private member functions. */
382         void prepareFunctionPointers();
383         void prepareTransformFeedback();
384         void prepareBuffer();
385         void prepareProgram();
386         void prepareVertexArrayObject();
387
388         bool draw();
389         bool testTransformFeedbackStatus(glw::GLenum parameter_name, glw::GLint expected_value);
390         bool verifyBufferContent();
391
392         void clean();
393
394         /* Private static variables. */
395         static const glw::GLuint                s_bo_size;
396         static const glw::GLchar                s_vertex_shader[];
397         static const glw::GLchar                s_fragment_shader[];
398         static const glw::GLchar* const s_xfb_varying;
399 };
400 /* FunctionalTest class */
401 } /* xfb namespace */
402
403 namespace Samplers
404 {
405 /** @class CreationTest
406  *
407  *  @brief Direct State Access Sampler Objects Creation test cases.
408  *
409  *  Test follows the steps:
410  *
411  *       Create at least two Sampler Objects names using GenSamplers function.
412  *       Check them without binding, using IsSampler function. Expect GL_FALSE.
413  *
414  *       Create at least two Sampler Objects using CreateSamplers function. Check
415  *       them without binding, using IsSampler function. Expect GL_TRUE.
416  *
417  *       Release objects.
418  */
419 class CreationTest : public deqp::TestCase
420 {
421 public:
422         /* Public member functions */
423         CreationTest(deqp::Context& context);
424
425         virtual tcu::TestNode::IterateResult iterate();
426
427 private:
428         /* Private member functions */
429         CreationTest(const CreationTest& other);
430         CreationTest& operator=(const CreationTest& other);
431 };
432 /* CreationTest class */
433
434 /** @class DefaultsTest
435  *
436  *  @brief Direct State Access Sampler Objects Default State test.
437  *
438  *         Test follows the steps:
439  *
440  *             Create Sampler Object with CreateSamplers function.
441  *
442  *             Verify that default value of TEXTURE_BORDER_COLOR queried with function
443  *             GetSamplerParameterfv is 0.0, 0.0, 0.0, 0.0.
444  *
445  *             Verify that default value of TEXTURE_COMPARE_FUNC queried with function
446  *             GetSamplerParameteriv is LEQUAL.
447  *
448  *             Verify that default value of TEXTURE_COMPARE_MODE queried with function
449  *             GetSamplerParameteriv is NONE.
450  *
451  *             Verify that default value of TEXTURE_LOD_BIAS queried with function
452  *             GetSamplerParameterfv is 0.0.
453  *
454  *             Verify that default value of TEXTURE_MAX_LOD queried with function
455  *             GetSamplerParameterfv is 1000.
456  *
457  *             Verify that default value of TEXTURE_MAG_FILTER queried with function
458  *             GetSamplerParameteriv is LINEAR.
459  *
460  *             Verify that default value of TEXTURE_MIN_FILTER queried with function
461  *             GetSamplerParameteriv is NEAREST_MIPMAP_LINEAR.
462  *
463  *             Verify that default value of TEXTURE_MIN_LOD queried with function
464  *             GetSamplerParameterfv is -1000.
465  *
466  *             Verify that default value of TEXTURE_WRAP_S queried with function
467  *             GetSamplerParameteriv is REPEAT.
468  *
469  *             Verify that default value of TEXTURE_WRAP_T queried with function
470  *             GetSamplerParameteriv is REPEAT.
471  *
472  *             Verify that default value of TEXTURE_WRAP_R queried with function
473  *             GetSamplerParameteriv is REPEAT.
474  *
475  *             Release objects.
476  */
477 class DefaultsTest : public deqp::TestCase
478 {
479 public:
480         /* Public member functions */
481         DefaultsTest(deqp::Context& context);
482
483         virtual tcu::TestNode::IterateResult iterate();
484
485 private:
486         /* Private member functions */
487         DefaultsTest(const DefaultsTest& other);
488         DefaultsTest& operator=(const DefaultsTest& other);
489
490         /* Private member variables */
491         glw::GLuint m_sampler_dsa;
492
493         /* Private member functions. */
494         void prepare();
495         bool testSamplerIntegerParameter(glw::GLenum pname, glw::GLint expected_value);
496         bool testSamplerFloatParameter(glw::GLenum pname, glw::GLfloat expected_value);
497         bool testSamplerFloatVectorParameter(glw::GLenum pname, glw::GLfloat expected_value[4]);
498         void clean();
499 };
500 /* DefaultsTest class */
501
502 /** @class ErrorsTest
503  *
504  *  @brief Direct State Access Samplers Negative test.
505  *
506  *         The test follows steps:
507  *
508  *             Check that CreateSamplers generates INVALID_VALUE error if
509  *             number of sampler objects to create is negative.
510  */
511 class ErrorsTest : public deqp::TestCase
512 {
513 public:
514         /* Public member functions */
515         ErrorsTest(deqp::Context& context);
516
517         virtual tcu::TestNode::IterateResult iterate();
518
519 private:
520         /* Private member functions */
521         ErrorsTest(const ErrorsTest& other);
522         ErrorsTest& operator=(const ErrorsTest& other);
523 };
524 /* ErrorsTest class */
525
526 /** @class FunctionalTest
527  *
528  *  @brief Direct State Access Samplers Functional test cases.
529  *
530  *  @note  The test follows steps:
531  *
532  *             Create framebuffer with renderbuffer with color attachment and 1x1 pixel
533  *             size. Clean framebuffer content with black color.
534  *
535  *             Create and bind empty vertex array object.
536  *
537  *             Build and use simple GLSL program drawing full screen textured quad
538  *             depending on VertexID. Fragment shader shall output texture point at
539  *             (1/3, 1/3).
540  *
541  *             Create texture 2 x 2 texels in size. Bind it. Upload texture with
542  *             following color data:
543  *                 RED,    GREEN,
544  *                 BLUE,   YELLOW.
545  *
546  *             Create Sampler object using CreateSamplers function and bind it to the
547  *             texture unit. Setup following sampler parameters:
548  *              *  TEXTURE_WRAP_S to the value of REPEAT,
549  *              *  TEXTURE_WRAP_T to REPEAT,
550  *              *  TEXTURE_MIN_FILTER to NEAREST,
551  *              *  TEXTURE_MAG_FILTER to NEAREST.
552  *
553  *             Draw full screen quad.
554  *
555  *             Fetch framebuffer content with ReadPixels function. Check that,
556  *             framebuffer is filled with red color.
557  *
558  *             Release objects.
559  */
560 class FunctionalTest : public deqp::TestCase
561 {
562 public:
563         /* Public member functions */
564         FunctionalTest(deqp::Context& context);
565
566         virtual tcu::TestNode::IterateResult iterate();
567
568 private:
569         /* Private member functions. */
570         FunctionalTest(const FunctionalTest& other);
571         FunctionalTest& operator=(const FunctionalTest& other);
572
573         void prepareFramebuffer();
574         void prepareVertexArrayObject();
575         void prepareProgram();
576         void prepareTexture();
577         void prepareSampler();
578         void draw();
579         bool checkFramebufferContent();
580         void clean();
581
582         /* Private member variables. */
583         glw::GLuint m_fbo;
584         glw::GLuint m_rbo;
585         glw::GLuint m_vao;
586         glw::GLuint m_to;
587         glw::GLuint m_so;
588         glw::GLuint m_po;
589
590         /* Private static variables. */
591         static const glw::GLchar  s_vertex_shader[];
592         static const glw::GLchar  s_fragment_shader[];
593         static const glw::GLchar  s_uniform_sampler[];
594         static const glw::GLubyte s_texture_data[];
595 };
596 /* FunctionalTest class */
597 } /* Samplers namespace */
598
599 namespace ProgramPipelines
600 {
601 /** @class CreationTest
602  *
603  *  @brief Direct State Access Program Pipeline Objects Creation test cases.
604  *
605  *  @note Test follows the steps:
606  *
607  *            Create at least two Program Pipeline Objects names using
608  *            GenProgramPipelines function. Check them without binding, using
609  *            IsProgramPipeline function. Expect GL_FALSE.
610  *
611  *            Create at least two Program Pipeline Objects using
612  *            CreateProgramPipelines function. Check them without binding, using
613  *            IsProgramPipeline function. Expect GL_TRUE.
614  *
615  *            Release objects.
616  */
617 class CreationTest : public deqp::TestCase
618 {
619 public:
620         /* Public member functions */
621         CreationTest(deqp::Context& context);
622
623         virtual tcu::TestNode::IterateResult iterate();
624
625 private:
626         /* Private member functions */
627         CreationTest(const CreationTest& other);
628         CreationTest& operator=(const CreationTest& other);
629 };
630 /* CreationTest class */
631
632 /** @class DefaultsTest
633  *
634  *  @brief Direct State Access Program Pipeline Objects Default State test.
635  *
636  *  @note Test follows the steps:
637  *
638  *            Create Program Pipeline Object with CreateProgramPipelines function.
639  *
640  *            Verify that default value of ACTIVE_PROGRAM queried with function
641  *            GetProgramPipelineiv is 0.
642  *
643  *            Verify that default value of VERTEX_SHADER queried with function
644  *            GetProgramPipelineiv is 0.
645  *
646  *            Verify that default value of GEOMETRY_SHADER queried with function
647  *            GetProgramPipelineiv is 0.
648  *
649  *            Verify that default value of FRAGMENT_SHADER queried with function
650  *            GetProgramPipelineiv is 0.
651  *
652  *            Verify that default value of COMPUTE_SHADER queried with function
653  *            GetProgramPipelineiv is 0.
654  *
655  *            Verify that default value of TESS_CONTROL_SHADER queried with function
656  *            GetProgramPipelineiv is 0.
657  *
658  *            Verify that default value of TESS_EVALUATION_SHADER queried with
659  *            function GetProgramPipelineiv is 0.
660  *
661  *            Verify that default value of VALIDATE_STATUS queried with function
662  *            GetProgramPipelineiv is 0.
663  *
664  *            Verify that default value of info log queried with function
665  *            GetProgramPiplineInfoLog is 0.
666  *
667  *            Verify that default value of INFO_LOG_LENGTH queried with function
668  *            GetProgramPipelineiv is 0.
669  *
670  *            Release object.
671  */
672 class DefaultsTest : public deqp::TestCase
673 {
674 public:
675         /* Public member functions */
676         DefaultsTest(deqp::Context& context);
677
678         virtual tcu::TestNode::IterateResult iterate();
679
680 private:
681         /* Private member functions */
682         DefaultsTest(const DefaultsTest& other);
683         DefaultsTest& operator=(const DefaultsTest& other);
684
685         /* Private member variables */
686         glw::GLuint m_program_pipeline_dsa;
687
688         /* Private member functions. */
689         void prepare();
690         bool testProgramPipelineParameter(glw::GLenum pname, glw::GLint expected_value);
691         bool testProgramPipelineInfoLog(glw::GLchar* expected_value);
692         void clean();
693 };
694 /* DefaultsTest class */
695
696 /** @class ErrorsTest
697  *
698  *  @brief Direct State Access Program Pipeline Negative test.
699  *
700  *         The test follows steps:
701  *
702  *             Check that CreateProgramPipelines generates INVALID_VALUE error if
703  *             number of program pipeline objects to create is negative.
704  */
705 class ErrorsTest : public deqp::TestCase
706 {
707 public:
708         /* Public member functions */
709         ErrorsTest(deqp::Context& context);
710
711         virtual tcu::TestNode::IterateResult iterate();
712
713 private:
714         /* Private member functions */
715         ErrorsTest(const ErrorsTest& other);
716         ErrorsTest& operator=(const ErrorsTest& other);
717 };
718 /* ErrorsTest class */
719
720 /** @class FunctionalTest
721  *
722  *  @brief Direct State Access Program Pipeline Functional test cases.
723  *
724  *  @note  The test follows steps:
725  *
726  *             Create framebuffer with renderbuffer with color attachment and 1x1 pixel
727  *             size. Clean framebuffer content with black color.
728  *
729  *             Create and bind empty vertex array object.
730  *
731  *             Make sure that no GLSL program is being used.
732  *
733  *             Create two shader programs (with CreateShaderProgramv) - one vertex
734  *             shader and one fragment shader. The vertex shader shall output full
735  *             screen quad depending on VertexID. The fragment shader shall output red
736  *             color.
737  *
738  *             Create the Program Pipeline Object using CreateProgramPipelines
739  *             function. Bind it using BindProgramPipeline. Setup Program Pipeline
740  *             with the created shader programs using UseProgramStages.
741  *
742  *             Draw full screen quad.
743  *
744  *             Fetch framebuffer content with ReadPixels function. Check that,
745  *             framebuffer is filled with red color.
746  *
747  *             Release objects.
748  */
749 class FunctionalTest : public deqp::TestCase
750 {
751 public:
752         /* Public member functions */
753         FunctionalTest(deqp::Context& context);
754
755         virtual tcu::TestNode::IterateResult iterate();
756
757 private:
758         /* Private member functions. */
759         FunctionalTest(const FunctionalTest& other);
760         FunctionalTest& operator=(const FunctionalTest& other);
761
762         void prepareFramebuffer();
763         void prepareVertexArrayObject();
764         void prepareShaderPrograms();
765         void preparePipeline();
766         void draw();
767         bool checkFramebufferContent();
768         void clean();
769
770         /* Private member variables. */
771         glw::GLuint m_fbo;
772         glw::GLuint m_rbo;
773         glw::GLuint m_vao;
774         glw::GLuint m_spo_v;
775         glw::GLuint m_spo_f;
776         glw::GLuint m_ppo;
777
778         /* Private static variables. */
779         static const glw::GLchar* s_vertex_shader;
780         static const glw::GLchar* s_fragment_shader;
781 };
782 /* FunctionalTest class */
783 } /* ProgramPipelines namespace */
784
785 namespace Queries
786 {
787 /** @class CreationTest
788  *
789  *  @brief Direct State Access Queries Creation test cases.
790  *
791  *  @note Test follows the steps:
792  *
793  *            Create at least two Query Objects names using GenQueries function.
794  *            Check them without binding, using IsQuery function. Expect GL_FALSE.
795  *
796  *            Create at least two Query Objects using CreateQueries function. Check
797  *            them without binding, using IsQuery function. Expect GL_TRUE.
798  *
799  *            Release objects.
800  *
801  *            Repeat test for all of following supported targets:
802  *             -  SAMPLES_PASSED,
803  *             -  ANY_SAMPLES_PASSED,
804  *             -  ANY_SAMPLES_PASSED_CONSERVATIVE,
805  *             -  TIME_ELAPSED,
806  *             -  TIMESTAMP,
807  *             -  PRIMITIVES_GENERATED and
808  *             -  TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN.
809  *
810  *  See Ref. OpenGL 4.5 Core Profile, Section 4.2.
811  */
812 class CreationTest : public deqp::TestCase
813 {
814 public:
815         /* Public member functions */
816         CreationTest(deqp::Context& context);
817
818         virtual tcu::TestNode::IterateResult iterate();
819
820 private:
821         /* Private member functions */
822         CreationTest(const CreationTest& other);
823         CreationTest& operator=(const CreationTest& other);
824 };
825 /* CreationTest class */
826
827 /** @class DefaultsTest
828  *
829  *  @brief Direct State Access Queries Default State test.
830  *
831  *  @note Test follows the steps:
832  *
833  *            Create Query Object with CreateQueries function.
834  *
835  *            Verify that default value of QUERY_RESULT queried with function
836  *            GetQueryObjectuiv is 0 or FALSE.
837  *
838  *            Verify that default value of QUERY_RESULT_AVAILABLE queried with
839  *            function GetQueryObjectiv is TRUE.
840  *
841  *            Release object.
842  *
843  *            Repeat test for all of following supported targets:
844  *             -  SAMPLES_PASSED,
845  *             -  ANY_SAMPLES_PASSED,
846  *             -  ANY_SAMPLES_PASSED_CONSERVATIVE,
847  *             -  TIME_ELAPSED,
848  *             -  TIMESTAMP,
849  *             -  PRIMITIVES_GENERATED and
850  *             -  TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN.
851  *
852  *  See Ref. OpenGL 4.5 Core Profile, Section 4.2.
853  */
854 class DefaultsTest : public deqp::TestCase
855 {
856 public:
857         /* Public member functions */
858         DefaultsTest(deqp::Context& context);
859
860         virtual tcu::TestNode::IterateResult iterate();
861
862 private:
863         /* Private member functions */
864         DefaultsTest(const DefaultsTest& other);
865         DefaultsTest& operator=(const DefaultsTest& other);
866
867         /* Private member variables */
868         glw::GLuint m_query_dsa;
869
870         /* Private member functions. */
871         void prepare(const glw::GLenum target);
872         bool testQueryParameter(const glw::GLenum pname, const glw::GLuint expected_value, const glw::GLchar* target_name);
873         void clean();
874 };
875 /* DefaultsTest class */
876
877 /** @class ErrorsTest
878  *
879  *  @brief Direct State Access Queries Negative test.
880  *
881  *  @note The test follows steps:
882  *
883  *            Check that CreateQueries generates INVALID_VALUE error if number of
884  *            query objects to create is negative.
885  *
886  *            Check that CreateQueries generates INVALID_ENUM error if target is not
887  *            one of accepted values:
888  *             -  SAMPLES_PASSED,
889  *             -  ANY_SAMPLES_PASSED,
890  *             -  ANY_SAMPLES_PASSED_CONSERVATIVE,
891  *             -  TIME_ELAPSED,
892  *             -  TIMESTAMP,
893  *             -  PRIMITIVES_GENERATED or
894  *             -  TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN.
895  *
896  *            Check that GetQueryBufferObjectiv, GetQueryBufferObjectuiv,
897  *            GetQueryBufferObjecti64v and GetQueryBufferObjectui64v generate
898  *            INVALID_OPERATION error if <id> is not the name of a query object, or
899  *            if the query object named by <id> is currently active.
900  *
901  *            Check that GetQueryBufferObjectiv, GetQueryBufferObjectuiv,
902  *            GetQueryBufferObjecti64v and GetQueryBufferObjectui64v generate
903  *            INVALID_OPERATION error if <buffer> is not the name of an existing
904  *            buffer object.
905  *
906  *            Check that GetQueryBufferObjectiv, GetQueryBufferObjectuiv,
907  *            GetQueryBufferObjecti64v and GetQueryBufferObjectui64v generate
908  *            INVALID_ENUM error if <pname> is not QUERY_RESULT,
909  *            QUERY_RESULT_AVAILABLE, QUERY_RESULT_NO_WAIT or QUERY_TARGET.
910  *
911  *            Check that GetQueryBufferObjectiv, GetQueryBufferObjectuiv,
912  *            GetQueryBufferObjecti64v and GetQueryBufferObjectui64v generate
913  *            INVALID_OPERATION error if the query writes to a buffer object, and the
914  *            specified buffer offset would cause data to be written beyond the bounds
915  *            of that buffer object.
916  *
917  *            Check that GetQueryBufferObjectiv, GetQueryBufferObjectuiv,
918  *            GetQueryBufferObjecti64v and GetQueryBufferObjectui64v generate
919  *            INVALID_VALUE error if <offset> is negative.
920  *
921  *  See Ref. OpenGL 4.5 Core Profile, Section 4.2.
922  */
923 class ErrorsTest : public deqp::TestCase
924 {
925 public:
926         /* Public member functions */
927         ErrorsTest(deqp::Context& context);
928
929         virtual tcu::TestNode::IterateResult iterate();
930
931 private:
932         /* Private member functions */
933         ErrorsTest(const ErrorsTest& other);
934         ErrorsTest& operator=(const ErrorsTest& other);
935
936         /* Private member functions. */
937         bool testNegativeNumberOfObjects();
938         bool testInvalidTarget();
939         bool testInvalidQueryName();
940         bool testInvalidBufferName();
941         bool testInvalidParameterName();
942         bool testBufferOverflow();
943         bool testBufferNegativeOffset();
944
945         bool isTarget(glw::GLenum maybe_target);
946         bool isParameterName(glw::GLenum maybe_pname);
947
948         /* Function pointers. */
949         typedef void(GLW_APIENTRY* PFNGLGETQUERYBUFFEROBJECT)(glw::GLuint id, glw::GLuint buffer, glw::GLenum pname,
950                                                                                                                   glw::GLintptr offset);
951
952         PFNGLGETQUERYBUFFEROBJECT m_pGetQueryBufferObjectiv;
953         PFNGLGETQUERYBUFFEROBJECT m_pGetQueryBufferObjectuiv;
954         PFNGLGETQUERYBUFFEROBJECT m_pGetQueryBufferObjecti64v;
955         PFNGLGETQUERYBUFFEROBJECT m_pGetQueryBufferObjectui64v;
956
957         /* Private static variables. */
958         static const glw::GLenum  s_targets[];
959         static const glw::GLchar* s_target_names[];
960         static const glw::GLuint  s_targets_count;
961 };
962 /* ErrorsTest class */
963
964 /** @class FunctionalTest
965  *
966  *  @brief Direct State Access Queries Functional test cases.
967  *
968  *  @note The test follows steps:
969  *
970  *            Create framebuffer with renderbuffer with color attachment and 1x1 pixel
971  *            size. Clean framebuffer content with black color.
972  *
973  *            Create and bind empty vertex array object.
974  *
975  *            Create buffer object. Bind it to TRANFORM_FEEDBACK_BUFFER binding point.
976  *            Bind buffer base to TRANFORM_FEEDBACK_BUFFER binding point with index 0.
977  *            Setup data storage of the buffer with size equal to 6 * sizeof(int).
978  *
979  *            Build GLSL program consisting of vertex and fragment shader stages.
980  *            Vertex shader shall output full screen quad depending on VertexID. The
981  *            VertexID shall be saved to transform feedback varying. Fragment shader
982  *            shall output red color.
983  *
984  *            Create query objects with CreateQueries function for following targets:
985  *             -  SAMPLES_PASSED,
986  *             -  PRIMITIVES_GENERATED,
987  *             -  TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN,
988  *             -  TIME_ELAPSED.
989  *
990  *            Begin query for every target.
991  *
992  *            Begin transform feedback for TRIANGLES primitive type.
993  *
994  *            Draw full screen quad with TRIANGLE_STRIP primitive type.
995  *
996  *            End transform feedback.
997  *
998  *            End all queries.
999  *
1000  *            Call Finish function.
1001  *
1002  *            Check that framebuffer is filled with red color.
1003  *
1004  *            Check that transform feedback buffer contains successive primitive
1005  *            vertex ids (0, 1, 2,  2, 1, 3).
1006  *
1007  *            For every query objects, using GetQueryBufferObjectiv,
1008  *            GetQueryBufferObjectuiv, GetQueryBufferObjecti64v,
1009  *            GetQueryBufferObjectui64v functions do following comparisons:
1010  *
1011  *                Check that value of parameter QUERY_TARGET is equal to target.
1012  *
1013  *                Check that value of parameter QUERY_RESULT_AVAILABLE is TRUE.
1014  *
1015  *                Check that value of parameter QUERY_RESULT and QUERY_RESULT_NO_WAIT:
1016  *                 -  is equal to 1 if target is SAMPLES_PASSED; or
1017  *                 -  is equal to 2 if target is PRIMITIVES_GENERATED or
1018  *                    TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN; or
1019  *                 -  is positive if target is TIME_ELAPSED.
1020  *
1021  *            Release objects.
1022  */
1023 class FunctionalTest : public deqp::TestCase
1024 {
1025 public:
1026         /* Public member functions */
1027         FunctionalTest(deqp::Context& context);
1028
1029         virtual tcu::TestNode::IterateResult iterate();
1030
1031 private:
1032         /* Private member functions. */
1033         FunctionalTest(const FunctionalTest& other);
1034         FunctionalTest& operator=(const FunctionalTest& other);
1035
1036         /* Function pointers. */
1037         typedef void(GLW_APIENTRY* PFNGLGETQUERYBUFFEROBJECT)(glw::GLuint id, glw::GLuint buffer, glw::GLenum pname,
1038                                                                                                                   glw::GLintptr offset);
1039
1040         PFNGLGETQUERYBUFFEROBJECT m_pGetQueryBufferObjectiv;
1041         PFNGLGETQUERYBUFFEROBJECT m_pGetQueryBufferObjectuiv;
1042         PFNGLGETQUERYBUFFEROBJECT m_pGetQueryBufferObjecti64v;
1043         PFNGLGETQUERYBUFFEROBJECT m_pGetQueryBufferObjectui64v;
1044
1045         /* Private templated functions. */
1046         template <typename T>
1047         static bool equal(T, T);
1048
1049         template <typename T>
1050         static bool less(T, T);
1051
1052         template <typename T>
1053         void GetQueryBufferObject(glw::GLuint id, glw::GLuint buffer, glw::GLenum pname, glw::GLintptr offset);
1054
1055         template <typename T>
1056         bool checkQueryBufferObject(glw::GLuint query, glw::GLenum pname, T expected_value, bool (*comparison)(T, T));
1057
1058         /* Private member functions. */
1059         void prepareView();
1060         void prepareVertexArray();
1061         void prepareBuffers();
1062         void prepareQueries();
1063         void prepareProgram();
1064         void draw();
1065         bool checkView();
1066         bool checkXFB();
1067         void clean();
1068
1069         /* Private member variables. */
1070         glw::GLuint  m_fbo;
1071         glw::GLuint  m_rbo;
1072         glw::GLuint  m_vao;
1073         glw::GLuint  m_bo_query;
1074         glw::GLuint  m_bo_xfb;
1075         glw::GLuint* m_qo;
1076         glw::GLuint  m_po;
1077
1078         /* Private static variables. */
1079         static const glw::GLenum s_targets[];
1080         static const glw::GLuint s_targets_count;
1081
1082         static const glw::GLint s_results[];
1083
1084         static const glw::GLchar  s_vertex_shader[];
1085         static const glw::GLchar  s_fragment_shader[];
1086         static const glw::GLchar* s_xfb_varying_name;
1087 };
1088 /* FunctionalTest class */
1089 } /* Queries namespace */
1090
1091 namespace Buffers
1092 {
1093 /** @class CreationTest
1094  *
1095  *  @brief Direct State Access Buffers Creation test cases.
1096  *
1097  *         Test follows the steps:
1098  *
1099  *             Create at least two buffer objects using GenBuffers function. Check
1100  *             them without binding, using IsBuffer function. Expect GL_FALSE.
1101  *
1102  *             Create at least two buffer objects using CreateBuffers function. Check
1103  *             them without binding, using IsBuffer function. Expect GL_TRUE.
1104  *
1105  *             Release objects.
1106  */
1107 class CreationTest : public deqp::TestCase
1108 {
1109 public:
1110         /* Public member functions */
1111         CreationTest(deqp::Context& context);
1112
1113         virtual tcu::TestNode::IterateResult iterate();
1114
1115 private:
1116         /* Private member functions */
1117         CreationTest(const CreationTest& other);
1118         CreationTest& operator=(const CreationTest& other);
1119 };
1120 /* CreationTest class */
1121
1122 /** @class DataTest
1123  *
1124  *  @brief Direct State Access Buffers Data test cases.
1125  *
1126  *         Test follows the steps:
1127  *
1128  *             Prepare test case with following steps:
1129  *
1130  *             Create buffer object using CreateBuffers.
1131  *
1132  *             Create data storage using given function and reference data.
1133  *
1134  *             Bind buffer.
1135  *
1136  *             Check buffer content using MapBuffer function.
1137  *
1138  *             Release objects.
1139  *
1140  *             Repeat the test case with function for data creation:
1141  *              -  NamedBufferData,
1142  *              -  NamedBufferData and it with NamedBufferSubData,
1143  *              -  NamedBufferStorage,
1144  *              -  CopyNamedBufferSubData from auxiliary buffer.
1145  *
1146  *             If NamedBufferData function is used then repeat the test case for
1147  *             usage:
1148  *              -  STREAM_DRAW,
1149  *              -  STREAM_READ,
1150  *              -  STREAM_COPY,
1151  *              -  STATIC_DRAW,
1152  *              -  STATIC_READ,
1153  *              -  STATIC_COPY,
1154  *              -  DYNAMIC_DRAW,
1155  *              -  DYNAMIC_READ, and
1156  *              -  DYNAMIC_COPY.
1157  *
1158  *             If NamedBufferStorage function is used then repeat the test case using
1159  *             flag MAP_READ_BIT and one of following:
1160  *              -  DYNAMIC_STORAGE_BIT,
1161  *              -  MAP_WRITE_BIT,
1162  *              -  MAP_PERSISTENT_BIT,
1163  *              -  MAP_COHERENT_BIT and
1164  *              -  CLIENT_STORAGE_BIT.
1165  */
1166 class DataTest : public deqp::TestCase
1167 {
1168 public:
1169         /* Public member functions */
1170         DataTest(deqp::Context& context);
1171
1172         virtual tcu::TestNode::IterateResult iterate();
1173
1174 private:
1175         /* Private member functions */
1176         DataTest(const DataTest& other);
1177         DataTest& operator=(const DataTest& other);
1178
1179         typedef void(GLW_APIENTRY* PFNGLNAMEDBUFFERDATA)(glw::GLuint buffer, glw::GLsizei size, const glw::GLvoid* data,
1180                                                                                                          glw::GLenum usage);
1181         typedef void(GLW_APIENTRY* PFNGLNAMEDBUFFERSUBDATA)(glw::GLuint buffer, glw::GLintptr offset, glw::GLsizei size,
1182                                                                                                                 const glw::GLvoid* data);
1183         typedef void(GLW_APIENTRY* PFNGLNAMEDBUFFERSTORAGE)(glw::GLuint buffer, glw::GLsizeiptr size,
1184                                                                                                                 const glw::GLvoid* data, glw::GLbitfield flags);
1185         typedef void(GLW_APIENTRY* PFNGLCOPYNAMEDBUFFERSUBDATA)(glw::GLuint readBuffer, glw::GLuint writeBuffer,
1186                                                                                                                         glw::GLintptr readOffset, glw::GLintptr writeOffset,
1187                                                                                                                         glw::GLsizeiptr size);
1188
1189         PFNGLNAMEDBUFFERDATA            m_pNamedBufferData;
1190         PFNGLNAMEDBUFFERSUBDATA         m_pNamedBufferSubData;
1191         PFNGLNAMEDBUFFERSTORAGE         m_pNamedBufferStorage;
1192         PFNGLCOPYNAMEDBUFFERSUBDATA m_pCopyNamedBufferSubData;
1193
1194         bool TestCase(void (DataTest::*UploadDataFunction)(glw::GLuint, glw::GLenum), glw::GLenum parameter);
1195
1196         void UploadUsingNamedBufferData(glw::GLuint id, glw::GLenum parameter);
1197         void UploadUsingNamedBufferSubData(glw::GLuint id, glw::GLenum parameter);
1198         void UploadUsingNamedBufferStorage(glw::GLuint id, glw::GLenum parameter);
1199         void UploadUsingCopyNamedBufferSubData(glw::GLuint id, glw::GLenum parameter);
1200
1201         bool compare(const glw::GLuint* data, const glw::GLuint* reference, const glw::GLsizei count);
1202         void LogFail(void (DataTest::*UploadDataFunction)(glw::GLuint, glw::GLenum), glw::GLenum parameter,
1203                                  const glw::GLuint* data, const glw::GLuint* reference, const glw::GLsizei count);
1204         void LogError(void (DataTest::*UploadDataFunction)(glw::GLuint, glw::GLenum), glw::GLenum parameter);
1205
1206         static const glw::GLuint  s_reference[];
1207         static const glw::GLsizei s_reference_size;
1208         static const glw::GLsizei s_reference_count;
1209 };
1210 /* DataTest class */
1211
1212 /** @class ClearTest
1213  *
1214  *  @brief Direct State Access Buffers Clear test cases.
1215  *
1216  *         Test follows the steps:
1217  *
1218  *             Prepare test case with following steps:
1219  *
1220  *                 Create buffer object using CreateBuffers.
1221  *
1222  *                 Create data storage using NamedBufferData without data
1223  *                 specification.
1224  *
1225  *                 Clear buffer content using given function.
1226  *
1227  *                 Bind buffer.
1228  *
1229  *                 Check buffer content using MapBuffer function.
1230  *
1231  *                 Release objects.
1232  *
1233  *             Repeat test case for following clear functions:
1234  *              -  ClearNamedBufferData and
1235  *              -  ClearNamedBufferSubData.
1236  *
1237  *             Repeat test case for following internal formats:
1238  *              -  GL_R8,
1239  *              -  GL_R16,
1240  *              -  GL_R16F,
1241  *              -  GL_R32F,
1242  *              -  GL_R8I,
1243  *              -  GL_R16I,
1244  *              -  GL_R32I,
1245  *              -  GL_R8UI,
1246  *              -  GL_R16UI,
1247  *              -  GL_R32UI,
1248  *              -  GL_RG8,
1249  *              -  GL_RG16,
1250  *              -  GL_RG16F,
1251  *              -  GL_RG32F,
1252  *              -  GL_RG8I,
1253  *              -  GL_RG16I,
1254  *              -  GL_RG32I,
1255  *              -  GL_RG8UI,
1256  *              -  GL_RG16UI,
1257  *              -  GL_RG32UI,
1258  *              -  GL_RGB32F,
1259  *              -  GL_RGB32I,
1260  *              -  GL_RGB32UI,
1261  *              -  GL_RGBA8,
1262  *              -  GL_RGBA16,
1263  *              -  GL_RGBA16F,
1264  *              -  GL_RGBA32F,
1265  *              -  GL_RGBA8I,
1266  *              -  GL_RGBA16I,
1267  *              -  GL_RGBA32I,
1268  *              -  GL_RGBA8UI,
1269  *              -  GL_RGBA16UI and
1270  *              -  GL_RGBA32UI.
1271  */
1272 class ClearTest : public deqp::TestCase
1273 {
1274 public:
1275         /* Public member functions */
1276         ClearTest(deqp::Context& context);
1277
1278         virtual tcu::TestNode::IterateResult iterate();
1279
1280 private:
1281         /* Private member functions */
1282         ClearTest(const ClearTest& other);
1283         ClearTest& operator=(const ClearTest& other);
1284
1285         typedef void(GLW_APIENTRY* PFNGLNAMEDBUFFERDATA)(glw::GLuint buffer, glw::GLsizei size, const glw::GLvoid* data,
1286                                                                                                          glw::GLenum usage);
1287         typedef void(GLW_APIENTRY* PFNGLCLEARNAMEDBUFFERDATA)(glw::GLuint buffer, glw::GLenum internalformat,
1288                                                                                                                   glw::GLenum format, glw::GLenum type,
1289                                                                                                                   const glw::GLvoid* data);
1290         typedef void(GLW_APIENTRY* PFNGLCLEARNAMEDBUFFERSUBDATA)(glw::GLuint buffer, glw::GLenum internalformat,
1291                                                                                                                          glw::GLintptr offset, glw::GLsizei size,
1292                                                                                                                          glw::GLenum format, glw::GLenum type,
1293                                                                                                                          const glw::GLvoid* data);
1294
1295         PFNGLNAMEDBUFFERDATA             m_pNamedBufferData;
1296         PFNGLCLEARNAMEDBUFFERDATA       m_pClearNamedBufferData;
1297         PFNGLCLEARNAMEDBUFFERSUBDATA m_pClearNamedBufferSubData;
1298
1299         template <typename T, bool USE_SUB_DATA>
1300         bool TestClearNamedBufferData(glw::GLenum internalformat, glw::GLsizei count, glw::GLenum format, glw::GLenum type,
1301                                                                   T* data);
1302
1303         template <bool USE_SUB_DATA>
1304         void ClearNamedBuffer(glw::GLuint buffer, glw::GLenum internalformat, glw::GLsizei size, glw::GLenum format,
1305                                                   glw::GLenum type, glw::GLvoid* data);
1306
1307         template <typename T>
1308         bool Compare(const T* data, const T* reference, const glw::GLsizei count);
1309
1310         template <typename T>
1311         void LogFail(bool use_sub_data, glw::GLenum internalformat, const T* data, const T* reference,
1312                                  const glw::GLsizei count);
1313
1314         void LogError(bool use_sub_data, glw::GLenum internalformat);
1315 };
1316 /* ClearTest class */
1317
1318 /** @class MapReadOnlyTest
1319  *
1320  *  @brief Direct State Access Buffers Map Read Only test cases.
1321  *
1322  *         Test follows the steps:
1323  *
1324  *             Create buffer object using CreateBuffers.
1325  *
1326  *             Create data storage using NamedBufferData function and reference
1327  *             data.
1328  *
1329  *             Map buffer with MapNamedBuffer function and READ_ONLY access flag.
1330  *
1331  *             Compare mapped buffer content with reference data.
1332  *
1333  *             Unmap buffer using UnmapNamedBuffer. Test if UnmapNamedBuffer
1334  *             returned GL_TRUE.
1335  *
1336  *             Release buffer.
1337  */
1338 class MapReadOnlyTest : public deqp::TestCase
1339 {
1340 public:
1341         /* Public member functions */
1342         MapReadOnlyTest(deqp::Context& context);
1343
1344         virtual tcu::TestNode::IterateResult iterate();
1345
1346 private:
1347         /* Private member functions */
1348         MapReadOnlyTest(const MapReadOnlyTest& other);
1349         MapReadOnlyTest& operator=(const MapReadOnlyTest& other);
1350
1351         /* API entry points. */
1352         typedef void(GLW_APIENTRY* PFNGLNAMEDBUFFERDATA)(glw::GLuint buffer, glw::GLsizei size, const glw::GLvoid* data,
1353                                                                                                          glw::GLenum usage);
1354         typedef void*(GLW_APIENTRY* PFNGLMAPNAMEDBUFFER)(glw::GLuint buffer, glw::GLenum access);
1355         typedef glw::GLboolean(GLW_APIENTRY* PFNGLUNMAPNAMEDBUFFER)(glw::GLuint buffer);
1356
1357         PFNGLNAMEDBUFFERDATA  m_pNamedBufferData;
1358         PFNGLMAPNAMEDBUFFER   m_pMapNamedBuffer;
1359         PFNGLUNMAPNAMEDBUFFER m_pUnmapNamedBuffer;
1360
1361         static const glw::GLuint  s_reference[];         //<! Reference data.
1362         static const glw::GLsizei s_reference_size;  //<! Reference data size.
1363         static const glw::GLsizei s_reference_count; //<! Reference data count (number of GLuint elements).
1364 };
1365 /* MapReadOnlyTest class */
1366
1367 /** @class MapReadWriteTest
1368  *
1369  *  @brief Direct State Access Buffers Map Read Write test cases.
1370  *
1371  *         Test follows the steps:
1372  *
1373  *             Create buffer object using CreateBuffers.
1374  *
1375  *             Create data storage using NamedBufferData function and reference
1376  *             data.
1377  *
1378  *             Map buffer with MapNamedBuffer function and READ_WRITE access flag.
1379  *
1380  *             Compare mapped buffer content with reference.
1381  *
1382  *             Write to the mapped buffer inverted reference content.
1383  *
1384  *             Unmap buffer.
1385  *
1386  *             Map buffer with MapNamedBuffer function and READ_WRITE access flag.
1387  *
1388  *             Compare mapped buffer content with inverted reference.
1389  *
1390  *             Unmap buffer.
1391  *
1392  *             Release buffer.
1393  */
1394 class MapReadWriteTest : public deqp::TestCase
1395 {
1396 public:
1397         /* Public member functions */
1398         MapReadWriteTest(deqp::Context& context);
1399
1400         virtual tcu::TestNode::IterateResult iterate();
1401
1402 private:
1403         /* Private member functions */
1404         MapReadWriteTest(const MapReadWriteTest& other);
1405         MapReadWriteTest& operator=(const MapReadWriteTest& other);
1406
1407         /* API entry points. */
1408         typedef void(GLW_APIENTRY* PFNGLNAMEDBUFFERDATA)(glw::GLuint buffer, glw::GLsizei size, const glw::GLvoid* data,
1409                                                                                                          glw::GLenum usage);
1410         typedef void*(GLW_APIENTRY* PFNGLMAPNAMEDBUFFER)(glw::GLuint buffer, glw::GLenum access);
1411         typedef glw::GLboolean(GLW_APIENTRY* PFNGLUNMAPNAMEDBUFFER)(glw::GLuint buffer);
1412
1413         PFNGLNAMEDBUFFERDATA  m_pNamedBufferData;
1414         PFNGLMAPNAMEDBUFFER   m_pMapNamedBuffer;
1415         PFNGLUNMAPNAMEDBUFFER m_pUnmapNamedBuffer;
1416
1417         static const glw::GLuint  s_reference[];         //<! Reference data.
1418         static const glw::GLsizei s_reference_size;  //<! Reference data size.
1419         static const glw::GLsizei s_reference_count; //<! Reference data count (number of GLuint elements).
1420 };
1421 /* MapReadWriteTest class */
1422
1423 /** @class MapWriteOnlyTest
1424  *
1425  *  @brief Direct State Access Buffers Map Write Only test cases.
1426  *
1427  *         Test follows the steps:
1428  *
1429  *             Create buffer object using CreateBuffers.
1430  *
1431  *             Create data storage using NamedBufferData function.
1432  *
1433  *             Map buffer with MapNamedBuffer function and WRITE_ONLY access flag.
1434  *
1435  *             Write reference data.
1436  *
1437  *             Unmap buffer.
1438  *
1439  *             Bind buffer to the binding point.
1440  *
1441  *             Map buffer with MapBuffer function and READ_ONLY access flag.
1442  *
1443  *             Compare mapped buffer content with reference.
1444  *
1445  *             Unmap buffer.
1446  *
1447  *             Release buffer.
1448  */
1449 class MapWriteOnlyTest : public deqp::TestCase
1450 {
1451 public:
1452         /* Public member functions */
1453         MapWriteOnlyTest(deqp::Context& context);
1454
1455         virtual tcu::TestNode::IterateResult iterate();
1456
1457 private:
1458         /* Private member functions */
1459         MapWriteOnlyTest(const MapWriteOnlyTest& other);
1460         MapWriteOnlyTest& operator=(const MapWriteOnlyTest& other);
1461
1462         /* API entry points. */
1463         typedef void(GLW_APIENTRY* PFNGLNAMEDBUFFERDATA)(glw::GLuint buffer, glw::GLsizei size, const glw::GLvoid* data,
1464                                                                                                          glw::GLenum usage);
1465         typedef void*(GLW_APIENTRY* PFNGLMAPNAMEDBUFFER)(glw::GLuint buffer, glw::GLenum access);
1466         typedef glw::GLboolean(GLW_APIENTRY* PFNGLUNMAPNAMEDBUFFER)(glw::GLuint buffer);
1467
1468         PFNGLNAMEDBUFFERDATA  m_pNamedBufferData;
1469         PFNGLMAPNAMEDBUFFER   m_pMapNamedBuffer;
1470         PFNGLUNMAPNAMEDBUFFER m_pUnmapNamedBuffer;
1471
1472         static const glw::GLuint  s_reference[];         //<! Reference data.
1473         static const glw::GLsizei s_reference_size;  //<! Reference data size.
1474         static const glw::GLsizei s_reference_count; //<! Reference data count (number of GLuint elements).
1475 };
1476 /* MapReadOnlyTest class */
1477
1478 /** @class MapRangeReadBitTest
1479  *
1480  *  @brief Direct State Access Buffers Range Map Read Bit test cases.
1481  *
1482  *         Test follows the steps:
1483  *
1484  *             Create buffer object using CreateBuffers.
1485  *
1486  *             Create data storage using NamedBufferStorage function, reference
1487  *             data and MAP_READ_BIT access flag.
1488  *
1489  *             Map first half of buffer with MapNamedBufferRange and MAP_READ_BIT
1490  *             access flag.
1491  *
1492  *             Compare mapped buffer content with reference.
1493  *
1494  *             Unmap buffer.
1495  *
1496  *             Map second half of buffer with MapNamedBufferRange and MAP_READ_BIT
1497  *             access flag.
1498  *
1499  *             Compare mapped buffer content with reference.
1500  *
1501  *             Unmap buffer.
1502  *
1503  *             Release buffer.
1504  *
1505  *             Repeat the test with also MAP_PERSISTENT_BIT flag turned on.
1506  *
1507  *             Repeat the test with also MAP_PERSISTENT_BIT and MAP_COHERENT_BIT
1508  *             flags turned on.
1509  */
1510 class MapRangeReadBitTest : public deqp::TestCase
1511 {
1512 public:
1513         /* Public member functions */
1514         MapRangeReadBitTest(deqp::Context& context);
1515
1516         virtual tcu::TestNode::IterateResult iterate();
1517
1518 private:
1519         /* Private member functions */
1520         MapRangeReadBitTest(const MapRangeReadBitTest& other);
1521         MapRangeReadBitTest& operator=(const MapRangeReadBitTest& other);
1522
1523         /* API entry points. */
1524         typedef void(GLW_APIENTRY* PFNGLNAMEDBUFFERSTORAGE)(glw::GLuint buffer, glw::GLsizeiptr size,
1525                                                                                                                 const glw::GLvoid* data, glw::GLbitfield flags);
1526         typedef void*(GLW_APIENTRY* PFNGLMAPNAMEDBUFFERRANGE)(glw::GLuint buffer, glw::GLintptr offset, glw::GLsizei length,
1527                                                                                                                   glw::GLbitfield access);
1528         typedef glw::GLboolean(GLW_APIENTRY* PFNGLUNMAPNAMEDBUFFER)(glw::GLuint buffer);
1529
1530         PFNGLNAMEDBUFFERSTORAGE  m_pNamedBufferStorage;
1531         PFNGLMAPNAMEDBUFFERRANGE m_pMapNamedBufferRange;
1532         PFNGLUNMAPNAMEDBUFFER   m_pUnmapNamedBuffer;
1533
1534         bool CompareWithReference(glw::GLuint* data, glw::GLintptr offset, glw::GLsizei length);
1535
1536         static const glw::GLuint  s_reference[];         //<! Reference data.
1537         static const glw::GLsizei s_reference_size;  //<! Reference data size.
1538         static const glw::GLsizei s_reference_count; //<! Reference data count (number of GLuint elements).
1539 };
1540 /* MapRangeReadBitTest class */
1541
1542 /** @class MapRangeWriteBitTest
1543  *
1544  *  @brief Direct State Access Buffers Range Map Read Bit test cases.
1545  *
1546  *         Test follows the steps:
1547  *
1548  *             Create buffer object using CreateBuffers.
1549  *
1550  *             Create data storage using NamedBufferStorage function, reference
1551  *             data and (MAP_READ_BIT | MAP_WRITE_BIT) access flag.
1552  *
1553  *             Map first half of buffer with MapNamedBufferRange and MAP_WRITE_BIT
1554  *             access flag.
1555  *
1556  *             Write reference data.
1557  *
1558  *             Unmap buffer.
1559  *
1560  *             Map second half of buffer with MapNamedBufferRange and MAP_WRITE_BIT
1561  *             access flag.
1562  *
1563  *             Write reference data.
1564  *
1565  *             Unmap buffer.
1566  *
1567  *             Bind buffer to the binding point.
1568  *
1569  *             Map buffer with MapBuffer function and READ_ONLY access flag.
1570  *
1571  *             Compare mapped buffer content with reference.
1572  *
1573  *             Unmap buffer.
1574  *
1575  *             Release buffer.
1576  *
1577  *             Repeat the test with also MAP_INVALIDATE_RANGE_BIT flag turned on.
1578  *
1579  *             Repeat the test with also MAP_INVALIDATE_BUFFER_BIT flag turned on with
1580  *             only the first mapping.
1581  *
1582  *             Repeat the test with also MAP_FLUSH_EXPLICIT_BIT flag turned on. Make
1583  *             sure that all writes are flushed using FlushNamedMappedBufferRange
1584  *             function.
1585  *
1586  *             Repeat the test with also MAP_UNSYNCHRONIZED_BIT flag turned on with
1587  *             only the second mapping.
1588  */
1589 class MapRangeWriteBitTest : public deqp::TestCase
1590 {
1591 public:
1592         /* Public member functions */
1593         MapRangeWriteBitTest(deqp::Context& context);
1594
1595         virtual tcu::TestNode::IterateResult iterate();
1596
1597 private:
1598         /* Private member functions */
1599         MapRangeWriteBitTest(const MapRangeWriteBitTest& other);
1600         MapRangeWriteBitTest& operator=(const MapRangeWriteBitTest& other);
1601
1602         /* API entry points. */
1603         typedef void(GLW_APIENTRY* PFNGLNAMEDBUFFERSTORAGE)(glw::GLuint buffer, glw::GLsizeiptr size,
1604                                                                                                                 const glw::GLvoid* data, glw::GLbitfield flags);
1605         typedef void*(GLW_APIENTRY* PFNGLMAPNAMEDBUFFERRANGE)(glw::GLuint buffer, glw::GLintptr offset, glw::GLsizei length,
1606                                                                                                                   glw::GLbitfield access);
1607         typedef glw::GLboolean(GLW_APIENTRY* PFNGLUNMAPNAMEDBUFFER)(glw::GLuint buffer);
1608         typedef void(GLW_APIENTRY* PFNGLFLUSHMAPPEDNAMEDBUFFERRANGE)(glw::GLuint buffer, glw::GLintptr offset,
1609                                                                                                                                  glw::GLsizei length);
1610
1611         PFNGLNAMEDBUFFERSTORAGE                  m_pNamedBufferStorage;
1612         PFNGLMAPNAMEDBUFFERRANGE                 m_pMapNamedBufferRange;
1613         PFNGLUNMAPNAMEDBUFFER                    m_pUnmapNamedBuffer;
1614         PFNGLFLUSHMAPPEDNAMEDBUFFERRANGE m_pFlushMappedNamedBufferRange;
1615
1616         bool CompareWithReference(glw::GLuint buffer, glw::GLbitfield access_flag);
1617
1618         static const glw::GLuint  s_reference[];         //<! Reference data.
1619         static const glw::GLsizei s_reference_size;  //<! Reference data size.
1620         static const glw::GLsizei s_reference_count; //<! Reference data count (number of GLuint elements).
1621 };
1622 /* MapRangeWriteBitTest class */
1623
1624 /** @class SubDataQueryTest
1625  *
1626  *  @brief Direct State Access GetNamedBufferSubData Query test cases.
1627  *
1628  *         Test follows the steps:
1629  *
1630  *             Create buffer object using CreateBuffers.
1631  *
1632  *             Create data storage using NamedBufferData function and reference data.
1633  *
1634  *             Fetch first half of the buffer using GetNamedBufferSubData function.
1635  *
1636  *             Fetch second half of the buffer using GetNamedBufferSubData function.
1637  *
1638  *             Compare fetched data with reference values.
1639  *
1640  *             Release object.
1641  */
1642 class SubDataQueryTest : public deqp::TestCase
1643 {
1644 public:
1645         /* Public member functions */
1646         SubDataQueryTest(deqp::Context& context);
1647
1648         virtual tcu::TestNode::IterateResult iterate();
1649
1650 private:
1651         /* Private member functions */
1652         SubDataQueryTest(const SubDataQueryTest& other);
1653         SubDataQueryTest& operator=(const SubDataQueryTest& other);
1654
1655         /* API entry points. */
1656         typedef void(GLW_APIENTRY* PFNGLNAMEDBUFFERDATA)(glw::GLuint buffer, glw::GLsizei size, const glw::GLvoid* data,
1657                                                                                                          glw::GLenum usage);
1658         typedef void*(GLW_APIENTRY* PFNGLGETNAMEDBUFFERSUBDATA)(glw::GLuint buffer, glw::GLintptr offset, glw::GLsizei size,
1659                                                                                                                         glw::GLvoid* data);
1660
1661         PFNGLNAMEDBUFFERDATA       m_pNamedBufferData;
1662         PFNGLGETNAMEDBUFFERSUBDATA m_pGetNamedBufferSubData;
1663
1664         static const glw::GLuint  s_reference[];         //<! Reference data.
1665         static const glw::GLsizei s_reference_size;  //<! Reference data size.
1666         static const glw::GLsizei s_reference_count; //<! Reference data count (number of GLuint elements).
1667 };
1668 /* SubDataQueryTest class */
1669
1670 /** @class DefaultsTest
1671  *
1672  *  @brief Direct State Access Buffer Objects Default Values Test.
1673  *
1674  *         Test follows the steps:
1675  *
1676  *             Create buffer object using CreateBuffers.
1677  *
1678  *             Check that GetNamedBufferParameteriv and GetNamedBufferParameteri64v
1679  *             function called with parameter name
1680  *              -  BUFFER_SIZE returns value equal to 0;
1681  *              -  BUFFER_USAGE returns value equal to STATIC_DRAW;
1682  *              -  BUFFER_ACCESS returns value equal to READ_WRITE;
1683  *              -  BUFFER_ACCESS_FLAGS returns value equal to 0;
1684  *              -  BUFFER_IMMUTABLE_STORAGE returns value equal to FALSE;
1685  *              -  BUFFER_MAPPED returns value equal to FALSE;
1686  *              -  BUFFER_MAP_OFFSET returns value equal to 0;
1687  *              -  BUFFER_MAP_LENGTH returns value equal to 0;
1688  *              -  BUFFER_STORAGE_FLAGS returns value equal to 0.
1689  *
1690  *            Check that GetNamedBufferPointerv function called with parameter name
1691  *            BUFFER_MAP_POINTER returns value equal to NULL;
1692  */
1693 class DefaultsTest : public deqp::TestCase
1694 {
1695 public:
1696         /* Public member functions */
1697         DefaultsTest(deqp::Context& context);
1698
1699         virtual tcu::TestNode::IterateResult iterate();
1700
1701 private:
1702         /* Private member functions */
1703         DefaultsTest(const DefaultsTest& other);
1704         DefaultsTest& operator=(const DefaultsTest& other);
1705
1706         bool CheckParameterError(const glw::GLchar* pname_string, const glw::GLchar* function_string);
1707
1708         template <typename T>
1709         bool CheckValue(const T value, const T reference_value, const glw::GLchar* pname_string,
1710                                         const glw::GLchar* function_string);
1711
1712         /* API entry points. */
1713         typedef void(GLW_APIENTRY* PFNGLNAMEDBUFFERDATA)(glw::GLuint buffer, glw::GLsizei size, const glw::GLvoid* data,
1714                                                                                                          glw::GLenum usage);
1715         typedef void(GLW_APIENTRY* PFNGLGETNAMEDBUFFERPARAMETERI64V)(glw::GLuint buffer, glw::GLenum pname,
1716                                                                                                                                  glw::GLint64* data);
1717         typedef void(GLW_APIENTRY* PFNGLGETNAMEDBUFFERPARAMETERIV)(glw::GLuint buffer, glw::GLenum pname, glw::GLint* data);
1718         typedef void(GLW_APIENTRY* PFNGLGETNAMEDBUFFERPOINTERV)(glw::GLuint buffer, glw::GLenum pname,
1719                                                                                                                         glw::GLvoid** params);
1720
1721         PFNGLNAMEDBUFFERDATA                     m_pNamedBufferData;
1722         PFNGLGETNAMEDBUFFERPARAMETERI64V m_pGetNamedBufferParameteri64v;
1723         PFNGLGETNAMEDBUFFERPARAMETERIV   m_pGetNamedBufferParameteriv;
1724         PFNGLGETNAMEDBUFFERPOINTERV              m_pGetNamedBufferPointerv;
1725 };
1726 /* DefaultsTest class */
1727
1728 /** @class ErrorsTest
1729  *
1730  *  @brief Direct State Access Buffer Objects Errors Test.
1731  *
1732  *         Test follows the steps:
1733  *
1734  *                     Check that INVALID_VALUE is generated by CreateBuffers if n is negative.
1735  *
1736  *
1737  *                     Check that INVALID_OPERATION is generated by NamedBufferStorage if
1738  *                     buffer is not the name of an existing buffer object.
1739  *
1740  *                     Check that INVALID_VALUE is generated by NamedBufferStorage if size is
1741  *                     less than or equal to zero.
1742  *
1743  *                     Check that INVALID_VALUE is generated by NamedBufferStorage if flags has
1744  *                     any bits set other than DYNAMIC_STORAGE_BIT, MAP_READ_BIT,
1745  *                     MAP_WRITE_BIT, MAP_PERSISTENT_BIT, MAP_COHERENT_BIT or
1746  *                     CLIENT_STORAGE_BIT.
1747  *
1748  *                     Check that INVALID_VALUE error is generated by NamedBufferStorage if
1749  *                     flags contains MAP_PERSISTENT_BIT but does not contain at least one of
1750  *                     MAP_READ_BIT or MAP_WRITE_BIT.
1751  *
1752  *                     Check that INVALID_VALUE is generated by NamedBufferStorage if flags
1753  *                     contains MAP_COHERENT_BIT, but does not also contain MAP_PERSISTENT_BIT.
1754  *
1755  *                     Check that OUT_OF_MEMORY is generated if the GL is unable to create a
1756  *                     data store with the specified size. Do not set result, if out of memory
1757  *                     situation was impossible to generate or unable to verify.
1758  *
1759  *
1760  *                     Check that INVALID_OPERATION is generated by NamedBufferData if buffer
1761  *                     is not the name of an existing buffer object.
1762  *
1763  *                     Check that INVALID_ENUM is generated by NamedBufferData if usage is not
1764  *                     STREAM_DRAW, STREAM_READ, STREAM_COPY, STATIC_DRAW, STATIC_READ,
1765  *                     STATIC_COPY, DYNAMIC_DRAW, DYNAMIC_READ or DYNAMIC_COPY.
1766  *
1767  *                     Check that INVALID_VALUE is generated by NamedBufferData if size is
1768  *                     negative.
1769  *
1770  *                     Check that INVALID_OPERATION is generated by NamedBufferData if the
1771  *                     BUFFER_IMMUTABLE_STORAGE flag of the buffer object is TRUE.
1772  *
1773  *                     Check that OUT_OF_MEMORY is generated if the GL is unable to create a
1774  *                     data store with the specified size. Do not set result, if out of memory
1775  *                     situation was impossible to generate or unable to verify.
1776  *
1777  *
1778  *                     Check that INVALID_OPERATION is generated by NamedBufferSubData if
1779  *                     buffer is not the name of an existing buffer object.
1780  *
1781  *                     Check that INVALID_VALUE is generated by NamedBufferSubData if offset or
1782  *                     size is negative, or if offset+size is greater than the value of
1783  *                     BUFFER_SIZE for the specified buffer object.
1784  *
1785  *                     Check that INVALID_OPERATION is generated by NamedBufferSubData if any
1786  *                     part of the specified range of the buffer object is mapped with
1787  *                     MapBufferRange or MapBuffer, unless it was mapped with the
1788  *                     MAP_PERSISTENT_BIT bit set in the MapBufferRange access flags.
1789  *
1790  *                     Check that INVALID_OPERATION is generated by NamedBufferSubData if the
1791  *                     value of the BUFFER_IMMUTABLE_STORAGE flag of the buffer object is TRUE
1792  *                     and the value of BUFFER_STORAGE_FLAGS for the buffer object does not
1793  *                     have the DYNAMIC_STORAGE_BIT bit set.
1794  *
1795  *
1796  *                     Check that INVALID_OPERATION is generated by ClearNamedBufferData if
1797  *                     buffer is not the name of an existing buffer object.
1798  *
1799  *                     Check that INVALID_ENUM is generated by ClearNamedBufferData if
1800  *                     internal format is not one of the valid sized internal formats listed in
1801  *                     the table above.
1802  *
1803  *                     Check that INVALID_OPERATION is generated by ClearNamedBufferData if
1804  *                     any part of the specified range of the buffer object is mapped with
1805  *                     MapBufferRange or MapBuffer, unless it was mapped with the
1806  *                     MAP_PERSISTENT_BIT bit set in the MapBufferRange access flags.
1807  *
1808  *                     Check that INVALID_VALUE is generated by ClearNamedBufferData if
1809  *                     format is not a valid format, or type is not a valid type.
1810  *
1811  *
1812  *                     Check that INVALID_OPERATION is generated by ClearNamedBufferSubData
1813  *                     if buffer is not the name of an existing buffer object.
1814  *
1815  *                     Check that INVALID_ENUM is generated by ClearNamedBufferSubData if
1816  *                     internal format is not one of the valid sized internal formats listed in
1817  *                     the table above.
1818  *
1819  *                     Check that INVALID_VALUE is generated by ClearNamedBufferSubData if
1820  *                     offset or range are not multiples of the number of basic machine units
1821  *                     per-element for the internal format specified by internal format. This
1822  *                     value may be computed by multiplying the number of components for
1823  *                     internal format from the table by the size of the base type from the
1824  *                     specification table.
1825  *
1826  *                     Check that INVALID_VALUE is generated by ClearNamedBufferSubData if
1827  *                     offset or size is negative, or if offset+size is greater than the value
1828  *                     of BUFFER_SIZE for the buffer object.
1829  *
1830  *                     Check that INVALID_OPERATION is generated by ClearNamedBufferSubData
1831  *                     if any part of the specified range of the buffer object is mapped with
1832  *                     MapBufferRange or MapBuffer, unless it was mapped with the
1833  *                     MAP_PERSISTENT_BIT bit set in the MapBufferRange access flags.
1834  *
1835  *                     Check that INVALID_VALUE is generated by ClearNamedBufferSubData if
1836  *                     format is not a valid format, or type is not a valid type.
1837  *
1838  *
1839  *                     Check that INVALID_OPERATION is generated by CopyNamedBufferSubData if
1840  *                     readBuffer or writeBuffer is not the name of an existing buffer object.
1841  *
1842  *                     Check that INVALID_VALUE is generated by CopyNamedBufferSubData if any of
1843  *                     readOffset, writeOffset or size is negative, if readOffset+size is
1844  *                     greater than the size of the source buffer object (its value of
1845  *                     BUFFER_SIZE), or if writeOffset+size is greater than the size of the
1846  *                     destination buffer object.
1847  *
1848  *                     Check that INVALID_VALUE is generated by CopyNamedBufferSubData if the
1849  *                     source and destination are the same buffer object, and the ranges
1850  *                     [readOffset,readOffset+size) and [writeOffset,writeOffset+size) overlap.
1851  *
1852  *                     Check that INVALID_OPERATION is generated by CopyNamedBufferSubData if
1853  *                     either the source or destination buffer object is mapped with
1854  *                     MapBufferRange or MapBuffer, unless they were mapped with the
1855  *                     MAP_PERSISTENT bit set in the MapBufferRange access flags.
1856  *
1857  *
1858  *                     Check that INVALID_OPERATION is generated by MapNamedBuffer if buffer is
1859  *                     not the name of an existing buffer object.
1860  *
1861  *                     Check that INVALID_ENUM is generated by MapNamedBuffer if access is not
1862  *                     READ_ONLY, WRITE_ONLY, or READ_WRITE.
1863  *
1864  *                     Check that INVALID_OPERATION is generated by MapNamedBuffer if the
1865  *                     buffer object is in a mapped state.
1866  *
1867  *
1868  *                     Check that INVALID_OPERATION is generated by MapNamedBufferRange if
1869  *                     buffer is not the name of an existing buffer object.
1870  *
1871  *                     Check that INVALID_VALUE is generated by MapNamedBufferRange if offset
1872  *                     or length is negative, if offset+length is greater than the value of
1873  *                     BUFFER_SIZE for the buffer object, or if access has any bits set other
1874  *                     than those defined above.
1875  *
1876  *                     Check that INVALID_OPERATION is generated by MapNamedBufferRange for any
1877  *                     of the following conditions:
1878  *                      -  length is zero.
1879  *                      -  The buffer object is already in a mapped state.
1880  *                      -  Neither MAP_READ_BIT nor MAP_WRITE_BIT is set.
1881  *                      -  MAP_READ_BIT is set and any of MAP_INVALIDATE_RANGE_BIT,
1882  *                         MAP_INVALIDATE_BUFFER_BIT or MAP_UNSYNCHRONIZED_BIT is set.
1883  *                      -  MAP_FLUSH_EXPLICIT_BIT is set and MAP_WRITE_BIT is not set.
1884  *                      -  Any of MAP_READ_BIT, MAP_WRITE_BIT, MAP_PERSISTENT_BIT, or
1885  *                         MAP_COHERENT_BIT are set, but the same bit is not included in the
1886  *                         buffer's storage flags.
1887  *
1888  *
1889  *                     Check that INVALID_OPERATION is generated by UnmapNamedBuffer if buffer
1890  *                     is not the name of an existing buffer object.
1891  *
1892  *                     Check that INVALID_OPERATION is generated by UnmapNamedBuffer if the
1893  *                     buffer object is not in a mapped state.
1894  *
1895  *
1896  *                     Check that INVALID_OPERATION is generated by FlushMappedNamedBufferRange
1897  *                     if buffer is not the name of an existing buffer object.
1898  *
1899  *                     Check that INVALID_VALUE is generated by FlushMappedNamedBufferRange if
1900  *                     offset or length is negative, or if offset + length exceeds the size of
1901  *                     the mapping.
1902  *
1903  *                     Check that INVALID_OPERATION is generated by FlushMappedNamedBufferRange
1904  *                     if the buffer object is not mapped, or is mapped without the
1905  *                     MAP_FLUSH_EXPLICIT_BIT flag.
1906  *
1907  *
1908  *                     Check that INVALID_OPERATION is generated by GetNamedBufferParameter* if
1909  *                     buffer is not the name of an existing buffer object.
1910  *
1911  *                     Check that INVALID_ENUM is generated by GetNamedBufferParameter* if
1912  *                     pname is not one of the buffer object parameter names: BUFFER_ACCESS,
1913  *                     BUFFER_ACCESS_FLAGS, BUFFER_IMMUTABLE_STORAGE, BUFFER_MAPPED,
1914  *                     BUFFER_MAP_LENGTH, BUFFER_MAP_OFFSET, BUFFER_SIZE, BUFFER_STORAGE_FLAGS,
1915  *                     BUFFER_USAGE.
1916  *
1917  *
1918  *                     Check that INVALID_OPERATION is generated by GetNamedBufferPointerv
1919  *                     if buffer is not the name of an existing buffer object.
1920  *
1921  *
1922  *                     Check that INVALID_OPERATION is generated by GetNamedBufferSubData if
1923  *                     buffer is not the name of an existing buffer object.
1924  *
1925  *                     Check that INVALID_VALUE is generated by GetNamedBufferSubData if offset
1926  *                     or size is negative, or if offset+size is greater than the value of
1927  *                     BUFFER_SIZE for the buffer object.
1928  *
1929  *                     Check that INVALID_OPERATION is generated by GetNamedBufferSubData if
1930  *                     the buffer object is mapped with MapBufferRange or MapBuffer, unless it
1931  *                     was mapped with the MAP_PERSISTENT_BIT bit set in the MapBufferRange
1932  *                     access flags.
1933  */
1934 class ErrorsTest : public deqp::TestCase
1935 {
1936 public:
1937         /* Public member functions */
1938         ErrorsTest(deqp::Context& context);
1939
1940         virtual tcu::TestNode::IterateResult iterate();
1941
1942 private:
1943         /* Private member functions */
1944         ErrorsTest(const ErrorsTest& other);
1945         ErrorsTest& operator=(const ErrorsTest& other);
1946
1947         /* API entry points. */
1948         typedef void(GLW_APIENTRY* PFNGLCLEARNAMEDBUFFERDATA)(glw::GLuint buffer, glw::GLenum internalformat,
1949                                                                                                                   glw::GLenum format, glw::GLenum type,
1950                                                                                                                   const glw::GLvoid* data);
1951         typedef void(GLW_APIENTRY* PFNGLCLEARNAMEDBUFFERSUBDATA)(glw::GLuint buffer, glw::GLenum internalformat,
1952                                                                                                                          glw::GLintptr offset, glw::GLsizei size,
1953                                                                                                                          glw::GLenum format, glw::GLenum type,
1954                                                                                                                          const glw::GLvoid* data);
1955         typedef void(GLW_APIENTRY* PFNGLCOPYNAMEDBUFFERSUBDATA)(glw::GLuint readBuffer, glw::GLuint writeBuffer,
1956                                                                                                                         glw::GLintptr readOffset, glw::GLintptr writeOffset,
1957                                                                                                                         glw::GLsizeiptr size);
1958         typedef void(GLW_APIENTRY* PFNGLFLUSHMAPPEDNAMEDBUFFERRANGE)(glw::GLuint buffer, glw::GLintptr offset,
1959                                                                                                                                  glw::GLsizei length);
1960         typedef void(GLW_APIENTRY* PFNGLGETNAMEDBUFFERPARAMETERI64V)(glw::GLuint buffer, glw::GLenum pname,
1961                                                                                                                                  glw::GLint64* data);
1962         typedef void(GLW_APIENTRY* PFNGLGETNAMEDBUFFERPARAMETERIV)(glw::GLuint buffer, glw::GLenum pname, glw::GLint* data);
1963         typedef void(GLW_APIENTRY* PFNGLGETNAMEDBUFFERPOINTERV)(glw::GLuint buffer, glw::GLenum pname,
1964                                                                                                                         glw::GLvoid** params);
1965         typedef void*(GLW_APIENTRY* PFNGLGETNAMEDBUFFERSUBDATA)(glw::GLuint buffer, glw::GLintptr offset, glw::GLsizei size,
1966                                                                                                                         glw::GLvoid* data);
1967         typedef void*(GLW_APIENTRY* PFNGLMAPNAMEDBUFFER)(glw::GLuint buffer, glw::GLenum access);
1968         typedef void*(GLW_APIENTRY* PFNGLMAPNAMEDBUFFERRANGE)(glw::GLuint buffer, glw::GLintptr offset, glw::GLsizei length,
1969                                                                                                                   glw::GLbitfield access);
1970         typedef void(GLW_APIENTRY* PFNGLNAMEDBUFFERDATA)(glw::GLuint buffer, glw::GLsizeiptr size, const glw::GLvoid* data,
1971                                                                                                          glw::GLenum usage);
1972         typedef void(GLW_APIENTRY* PFNGLNAMEDBUFFERSTORAGE)(glw::GLuint buffer, glw::GLsizeiptr size,
1973                                                                                                                 const glw::GLvoid* data, glw::GLbitfield flags);
1974         typedef void(GLW_APIENTRY* PFNGLNAMEDBUFFERSUBDATA)(glw::GLuint buffer, glw::GLintptr offset, glw::GLsizei size,
1975                                                                                                                 const glw::GLvoid* data);
1976         typedef glw::GLboolean(GLW_APIENTRY* PFNGLUNMAPNAMEDBUFFER)(glw::GLuint buffer);
1977
1978         PFNGLCLEARNAMEDBUFFERDATA                m_pClearNamedBufferData;
1979         PFNGLCLEARNAMEDBUFFERSUBDATA     m_pClearNamedBufferSubData;
1980         PFNGLCOPYNAMEDBUFFERSUBDATA              m_pCopyNamedBufferSubData;
1981         PFNGLFLUSHMAPPEDNAMEDBUFFERRANGE m_pFlushMappedNamedBufferRange;
1982         PFNGLGETNAMEDBUFFERPARAMETERI64V m_pGetNamedBufferParameteri64v;
1983         PFNGLGETNAMEDBUFFERPARAMETERIV   m_pGetNamedBufferParameteriv;
1984         PFNGLGETNAMEDBUFFERPOINTERV              m_pGetNamedBufferPointerv;
1985         PFNGLGETNAMEDBUFFERSUBDATA               m_pGetNamedBufferSubData;
1986         PFNGLMAPNAMEDBUFFER                              m_pMapNamedBuffer;
1987         PFNGLMAPNAMEDBUFFERRANGE                 m_pMapNamedBufferRange;
1988         PFNGLNAMEDBUFFERDATA                     m_pNamedBufferData;
1989         PFNGLNAMEDBUFFERSTORAGE                  m_pNamedBufferStorage;
1990         PFNGLNAMEDBUFFERSUBDATA                  m_pNamedBufferSubData;
1991         PFNGLUNMAPNAMEDBUFFER                    m_pUnmapNamedBuffer;
1992
1993         /* Private member functions */
1994         bool TestErrorsOfClearNamedBufferData();
1995         bool TestErrorsOfClearNamedBufferSubData();
1996         bool TestErrorsOfCopyNamedBufferSubData();
1997         bool TestErrorsOfCreateBuffers();
1998         bool TestErrorsOfFlushMappedNamedBufferRange();
1999         bool TestErrorsOfGetNamedBufferParameter();
2000         bool TestErrorsOfGetNamedBufferPointerv();
2001         bool TestErrorsOfGetNamedBufferSubData();
2002         bool TestErrorsOfMapNamedBuffer();
2003         bool TestErrorsOfMapNamedBufferRange();
2004         bool TestErrorsOfNamedBufferData();
2005         bool TestErrorsOfNamedBufferStorage();
2006         bool TestErrorsOfNamedBufferSubData();
2007         bool TestErrorsOfUnmapNamedBuffer();
2008
2009         bool ErrorCheckAndLog(const glw::GLchar* function_name, const glw::GLenum expected_error,
2010                                                   const glw::GLchar* when_shall_be_generated);
2011 };
2012 /* ErrorsTest class */
2013
2014 /** @class FunctionalTest
2015  *
2016  *  @brief Direct State Access Buffer Objects Functional Test.
2017  *
2018  *         This test verifies basic usage in rendering pipeline of the tested
2019  *         functions:
2020  *         -  ClearNamedBufferData,
2021  *         -  ClearNamedBufferSubData,
2022  *         -  CopyNamedBufferSubData,
2023  *         -  FlushMappedNamedBufferRange,
2024  *         -  GetNamedBufferParameteri64v,
2025  *         -  GetNamedBufferParameteriv,
2026  *         -  GetNamedBufferPointerv,
2027  *         -  GetNamedBufferSubData,
2028  *         -  MapNamedBuffer,
2029  *         -  MapNamedBufferRange,
2030  *         -  NamedBufferData,
2031  *         -  NamedBufferStorage,
2032  *         -  NamedBufferSubData and
2033  *         -  UnmapNamedBuffer.
2034  *
2035  *         Test follows the steps:
2036  *
2037  *             Prepare program with vertex shader and fragment shader. Fragment shader
2038  *             shall be pass-trough. Vertex shader shall have one integer input
2039  *             variable. Vertex shader shall output (to transform feedback) square of
2040  *             input variable. gl_Position shall be set up to vec4(0.0, 0.0, 0.0, 1.0).
2041  *             Build and use the program.
2042  *
2043  *             Create and bind empty vertex array object.
2044  *
2045  *             Prepare one buffer using CreateBuffers and NamedBufferStorage with size
2046  *             of 6 integers and passing pointer to data {1, 2, 3, 4, 5, 5} and dynamic
2047  *             storage flag set on. Clear (with 0) the first element with
2048  *             ClearNamedBufferSubData. Set second data element to 1 using
2049  *             NamedBufferSubData. Set third data element to 2 using MapNamedBuffer
2050  *             and UnmapNamedBuffer. Bind it to ARRAY_BUFFER binding point. Copy forth
2051  *             element into fifth element using CopyNamedBufferSubData. Set fourth data
2052  *             element using MapNamedBufferRange and FlushMappedNamedBuffer to 3.
2053  *             During mapping check that GetNamedBufferPointerv called with
2054  *             BUFFER_MAP_POINTER returns proper pointer. Unmap it using
2055  *             UnmapNamedBuffer function. Setup buffer as an input attribute to GLSL
2056  *             program. Consequently, the resulting buffer shall be {0, 1, 2, 3, 4, 5}.
2057  *
2058  *             Prepare one buffer using GenBuffers. Bind it to transform feedback.
2059  *             Allocate it's storage using NamedBufferData with size of 7 integers and
2060  *             passing pointer to data {0, 0, 0, 0, 0, 0, 36}. Set up this buffer as
2061  *             transform feedback output.
2062  *
2063  *             Begin transform feedback.
2064  *
2065  *             Draw six indices using points.
2066  *
2067  *             End transform feedback.
2068  *
2069  *             Query array buffer's parameter BUFFER_IMMUTABLE_STORAGE with
2070  *             GetNamedBufferParameteriv and compare with previous setup.
2071  *
2072  *             Query transform feedback buffer size with GetNamedBufferParameteri64v
2073  *             and compare with previous setup.
2074  *
2075  *             Fetch transform feedback buffer content using GetNamedBufferSubData and
2076  *             queried size.
2077  *
2078  *             Check that fetched data is equal to {0, 1, 4, 9, 16, 25, 36}.
2079  *
2080  *             If any check fails, test shall fail.
2081  *
2082  *             If any of the tested functions generates error, test shall fail.
2083  */
2084 class FunctionalTest : public deqp::TestCase
2085 {
2086 public:
2087         /* Public member functions */
2088         FunctionalTest(deqp::Context& context);
2089
2090         virtual tcu::TestNode::IterateResult iterate();
2091
2092 private:
2093         /* Private member functions */
2094         FunctionalTest(const FunctionalTest& other);
2095         FunctionalTest& operator=(const FunctionalTest& other);
2096
2097         /* API entry points. */
2098         typedef void(GLW_APIENTRY* PFNGLCLEARNAMEDBUFFERDATA)(glw::GLuint buffer, glw::GLenum internalformat,
2099                                                                                                                   glw::GLenum format, glw::GLenum type,
2100                                                                                                                   const glw::GLvoid* data);
2101         typedef void(GLW_APIENTRY* PFNGLCLEARNAMEDBUFFERSUBDATA)(glw::GLuint buffer, glw::GLenum internalformat,
2102                                                                                                                          glw::GLintptr offset, glw::GLsizei size,
2103                                                                                                                          glw::GLenum format, glw::GLenum type,
2104                                                                                                                          const glw::GLvoid* data);
2105         typedef void(GLW_APIENTRY* PFNGLCOPYNAMEDBUFFERSUBDATA)(glw::GLuint readBuffer, glw::GLuint writeBuffer,
2106                                                                                                                         glw::GLintptr readOffset, glw::GLintptr writeOffset,
2107                                                                                                                         glw::GLsizeiptr size);
2108         typedef void(GLW_APIENTRY* PFNGLFLUSHMAPPEDNAMEDBUFFERRANGE)(glw::GLuint buffer, glw::GLintptr offset,
2109                                                                                                                                  glw::GLsizei length);
2110         typedef void(GLW_APIENTRY* PFNGLGETNAMEDBUFFERPARAMETERI64V)(glw::GLuint buffer, glw::GLenum pname,
2111                                                                                                                                  glw::GLint64* data);
2112         typedef void(GLW_APIENTRY* PFNGLGETNAMEDBUFFERPARAMETERIV)(glw::GLuint buffer, glw::GLenum pname, glw::GLint* data);
2113         typedef void(GLW_APIENTRY* PFNGLGETNAMEDBUFFERPOINTERV)(glw::GLuint buffer, glw::GLenum pname,
2114                                                                                                                         glw::GLvoid** params);
2115         typedef void*(GLW_APIENTRY* PFNGLGETNAMEDBUFFERSUBDATA)(glw::GLuint buffer, glw::GLintptr offset, glw::GLsizei size,
2116                                                                                                                         glw::GLvoid* data);
2117         typedef void*(GLW_APIENTRY* PFNGLMAPNAMEDBUFFER)(glw::GLuint buffer, glw::GLenum access);
2118         typedef void*(GLW_APIENTRY* PFNGLMAPNAMEDBUFFERRANGE)(glw::GLuint buffer, glw::GLintptr offset, glw::GLsizei length,
2119                                                                                                                   glw::GLbitfield access);
2120         typedef void(GLW_APIENTRY* PFNGLNAMEDBUFFERDATA)(glw::GLuint buffer, glw::GLsizeiptr size, const glw::GLvoid* data,
2121                                                                                                          glw::GLenum usage);
2122         typedef void(GLW_APIENTRY* PFNGLNAMEDBUFFERSTORAGE)(glw::GLuint buffer, glw::GLsizeiptr size,
2123                                                                                                                 const glw::GLvoid* data, glw::GLbitfield flags);
2124         typedef void(GLW_APIENTRY* PFNGLNAMEDBUFFERSUBDATA)(glw::GLuint buffer, glw::GLintptr offset, glw::GLsizei size,
2125                                                                                                                 const glw::GLvoid* data);
2126         typedef glw::GLboolean(GLW_APIENTRY* PFNGLUNMAPNAMEDBUFFER)(glw::GLuint buffer);
2127
2128         PFNGLCLEARNAMEDBUFFERDATA                m_pClearNamedBufferData;
2129         PFNGLCLEARNAMEDBUFFERSUBDATA     m_pClearNamedBufferSubData;
2130         PFNGLCOPYNAMEDBUFFERSUBDATA              m_pCopyNamedBufferSubData;
2131         PFNGLFLUSHMAPPEDNAMEDBUFFERRANGE m_pFlushMappedNamedBufferRange;
2132         PFNGLGETNAMEDBUFFERPARAMETERI64V m_pGetNamedBufferParameteri64v;
2133         PFNGLGETNAMEDBUFFERPARAMETERIV   m_pGetNamedBufferParameteriv;
2134         PFNGLGETNAMEDBUFFERPOINTERV              m_pGetNamedBufferPointerv;
2135         PFNGLGETNAMEDBUFFERSUBDATA               m_pGetNamedBufferSubData;
2136         PFNGLMAPNAMEDBUFFER                              m_pMapNamedBuffer;
2137         PFNGLMAPNAMEDBUFFERRANGE                 m_pMapNamedBufferRange;
2138         PFNGLNAMEDBUFFERDATA                     m_pNamedBufferData;
2139         PFNGLNAMEDBUFFERSTORAGE                  m_pNamedBufferStorage;
2140         PFNGLNAMEDBUFFERSUBDATA                  m_pNamedBufferSubData;
2141         PFNGLUNMAPNAMEDBUFFER                    m_pUnmapNamedBuffer;
2142
2143         /* Private member variables. */
2144         glw::GLuint m_po;
2145         glw::GLuint m_vao;
2146         glw::GLuint m_bo_in;
2147         glw::GLuint m_bo_out;
2148         glw::GLint  m_attrib_location;
2149
2150         /* Private static variables. */
2151         static const glw::GLchar  s_vertex_shader[];
2152         static const glw::GLchar  s_fragment_shader[];
2153         static const glw::GLchar  s_vertex_shader_input_name[];
2154         static const glw::GLchar* s_vertex_shader_output_name;
2155
2156         static const glw::GLint s_initial_data_a[];
2157         static const glw::GLint s_initial_data_b[];
2158         static const glw::GLint s_expected_data[];
2159
2160         /* Private member functions */
2161         void BuildProgram();
2162         void PrepareVertexArrayObject();
2163         bool PrepareInputBuffer();
2164         bool PrepareOutputBuffer();
2165         void Draw();
2166         bool CheckArrayBufferImmutableFlag();
2167         bool CheckTransformFeedbackBufferSize();
2168         bool CheckTransformFeedbackResult();
2169         void Cleanup();
2170 };
2171 /* FunctionalTest class */
2172 } /* Buffers namespace */
2173
2174 namespace Framebuffers
2175 {
2176 /** Framebuffer Creation
2177  *
2178  *      Create at least two framebuffer objects using GenFramebuffers function.
2179  *      Check them without binding, using IsFramebuffer function. Expect FALSE.
2180  *
2181  *      Create at least two framebuffer objects using CreateFramebuffers
2182  *      function. Check them without binding, using IsFramebuffer function.
2183  *      Expect TRUE.
2184  *
2185  *      Release objects.
2186  */
2187 class CreationTest : public deqp::TestCase
2188 {
2189 public:
2190         /* Public member functions */
2191         CreationTest(deqp::Context& context);
2192
2193         virtual tcu::TestNode::IterateResult iterate();
2194
2195 private:
2196         /* Private member functions */
2197         CreationTest(const CreationTest& other);
2198         CreationTest& operator=(const CreationTest& other);
2199 };
2200 /* CreationTest class */
2201
2202 /** Framebuffer Renderbuffer Attachment
2203  *
2204  *      Create renderbuffer using GenRenderbuffers function. Bind it. Prepare
2205  *      its storage using RenderbufferStorage. Unbind it.
2206  *
2207  *      Create framebuffer using CreateFramebuffers. Setup renderbuffer storage.
2208  *      Attach the renderbuffer to the framebuffer using
2209  *      NamedFramebufferRenderbuffer function.
2210  *
2211  *      Bind framebuffer and check its status using CheckFramebufferStatus
2212  *      function call.
2213  *
2214  *      Clear the framebuffer's content with the reference value. Fetch the
2215  *      framebuffer's content using ReadPixels and compare it with reference
2216  *      values.
2217  *
2218  *      Repeat the test for following attachment types:
2219  *       -  COLOR_ATTACHMENTi for i from 0 to value of MAX_COLOR_ATTACHMENTS
2220  *          minus one,
2221  *       -  DEPTH_ATTACHMENT,
2222  *       -  STENCIL_ATTACHMENT and
2223  *       -  DEPTH_STENCIL_ATTACHMENT.
2224  */
2225 class RenderbufferAttachmentTest : public deqp::TestCase
2226 {
2227 public:
2228         /* Public member functions */
2229         RenderbufferAttachmentTest(deqp::Context& context);
2230
2231         virtual tcu::TestNode::IterateResult iterate();
2232
2233 private:
2234         /* Private member functions */
2235         RenderbufferAttachmentTest(const RenderbufferAttachmentTest& other);
2236         RenderbufferAttachmentTest& operator=(const RenderbufferAttachmentTest& other);
2237
2238         bool Test(glw::GLenum attachment, glw::GLenum internalformat);
2239         void Clean();
2240
2241         /* Private member variables. */
2242         glw::GLuint m_fbo;
2243         glw::GLuint m_rbo;
2244 };
2245 /* RenderbufferAttachmentTest class */
2246
2247 /** Named Framebuffer Texture Attachment
2248  *
2249  *      Create texture using CreateTexture function. Prepare its storage using
2250  *      TexStorage*D*.
2251  *
2252  *      Create framebuffer using CreateFramebuffers. Attach the texture to
2253  *      the framebuffer using NamedFramebufferTexture function. Repeat
2254  *      attachment for all texture levels.
2255  *
2256  *      Bind framebuffer and check its status using CheckFramebufferStatus
2257  *      function call.
2258  *
2259  *      Clear the framebuffer's content with the reference value. Fetch the
2260  *      framebuffer's content using ReadPixels and compare it with reference
2261  *      values.
2262  *
2263  *      Repeat the test for following attachment types:
2264  *       -  COLOR_ATTACHMENTi for i from 0 to value of MAX_COLOR_ATTACHMENTS
2265  *          minus one,
2266  *       -  DEPTH_ATTACHMENT,
2267  *       -  STENCIL_ATTACHMENT and
2268  *       -  DEPTH_STENCIL_ATTACHMENT.
2269  *
2270  *      Repeat the test for following texture targets:
2271  *       -  TEXTURE_RECTANGLE,
2272  *       -  TEXTURE_2D,
2273  *       -  TEXTURE_2D_MULTISAMPLE,
2274  *       -  TEXTURE_CUBE_MAP.
2275  *
2276  *      Repeat the test with each possible texture level, that is:
2277  *       -  0 for TEXTURE_RECTANGLE and TEXTURE_2D_MULTISAMPLE targets;
2278  *       -  from zero to value one less than base 2 logarithm of the value of
2279  *          MAX_3D_TEXTURE_SIZE for TEXTURE_2D target
2280  *       -  from zero to value one less than base 2 logarithm of the value of
2281  *          MAX_CUBE_MAP_TEXTURE_SIZE for TEXTURE_CUBE_MAP target.
2282  */
2283 class TextureAttachmentTest : public deqp::TestCase
2284 {
2285 public:
2286         /* Public member functions */
2287         TextureAttachmentTest(deqp::Context& context);
2288
2289         virtual tcu::TestNode::IterateResult iterate();
2290
2291 private:
2292         /* Private member functions */
2293         TextureAttachmentTest(const TextureAttachmentTest& other);
2294         TextureAttachmentTest& operator=(const TextureAttachmentTest& other);
2295
2296         bool Test(glw::GLenum attachment, bool is_color_attachment, glw::GLenum texture_target, glw::GLenum internalformat,
2297                           glw::GLuint levels);
2298         bool SubTestAttachmentError(glw::GLenum attachment, glw::GLenum texture_target, glw::GLuint level,
2299                                                                 glw::GLuint levels);
2300         bool SubTestStatus(glw::GLenum attachment, glw::GLenum texture_target, glw::GLuint level, glw::GLuint levels);
2301         bool SubTestContent(glw::GLenum attachment, glw::GLenum texture_target, glw::GLenum internalformat,
2302                                                 glw::GLuint level, glw::GLuint levels);
2303         glw::GLuint MaxTextureLevels(glw::GLenum texture_target);
2304         void Clear();
2305         void Clean();
2306
2307         /* Private member variables. */
2308         glw::GLuint m_fbo;
2309         glw::GLuint m_to;
2310
2311         /* Static private variables. */
2312         static const glw::GLenum s_targets[];
2313         static const glw::GLuint s_targets_count;
2314
2315         static const glw::GLfloat s_reference_color[4];
2316         static const glw::GLint   s_reference_color_integer[4];
2317         static const glw::GLfloat s_reference_depth;
2318         static const glw::GLint   s_reference_stencil;
2319 };
2320 /* TextureAttachmentTest class */
2321
2322 /** Named Framebuffer Texture Layer Attachment
2323  *
2324  *      Create texture using CreateTexture function. Prepare its storage using
2325  *      TexStorage*D*.
2326  *
2327  *      Create framebuffer using CreateFramebuffers. Attach the texture to the
2328  *      framebuffer using NamedFramebufferTextureLayer function.
2329  *
2330  *      Bind framebuffer and check its status using CheckFramebufferStatus
2331  *      function call.
2332  *
2333  *      For non multisample target, clean the framebuffer's content with the
2334  *      reference value. Fetch one pixel from framebuffer's content using
2335  *      ReadPixels and compare it with reference values.
2336  *
2337  *      Repeat the test for following attachment types:
2338  *       -  COLOR_ATTACHMENTi for i from 0 to value of MAX_COLOR_ATTACHMENTS
2339  *          minus one,
2340  *       -  DEPTH_ATTACHMENT,
2341  *       -  STENCIL_ATTACHMENT and
2342  *       -  DEPTH_STENCIL_ATTACHMENT.
2343  *
2344  *      Repeat the test for following texture targets:
2345  *       -  TEXTURE_2D_MULTISAMPLE_ARRAY,
2346  *       -  TEXTURE_2D_ARRAY,
2347  *       -  TEXTURE_CUBE_MAP_ARRAY,
2348  *       -  TEXTURE_3D.
2349  *
2350  *      Repeat the test for texture levels from zero to value one less than base
2351  *      2 logarithm of the value of MAX_3D_TEXTURE_SIZE.
2352  *
2353  *      Repeat with texture which has number of layers:
2354  *       -  1,
2355  *       -  256,
2356  *       -  value of MAX_CUBE_MAP_TEXTURE_SIZE for TEXTURE_CUBE_ARRAY or value
2357  *          of MAX_3D_TEXTURE_SIZE.
2358  *      Test only limited set of the layers of the above textures to reduce time
2359  *      complexity of the test.
2360  */
2361 class TextureLayerAttachmentTest : public deqp::TestCase
2362 {
2363 public:
2364         /* Public member functions */
2365         TextureLayerAttachmentTest(deqp::Context& context);
2366
2367         virtual tcu::TestNode::IterateResult iterate();
2368
2369 private:
2370         /* Private member functions */
2371         TextureLayerAttachmentTest(const TextureLayerAttachmentTest& other);
2372         TextureLayerAttachmentTest& operator=(const TextureLayerAttachmentTest& other);
2373
2374         bool Test(glw::GLenum attachment, bool is_color_attachment, glw::GLenum texture_target, glw::GLenum internalformat,
2375                           glw::GLuint levels, glw::GLint layers);
2376         bool SubTestAttachmentError(glw::GLenum attachment, glw::GLenum texture_target, glw::GLuint level, glw::GLint layer,
2377                                                                 glw::GLuint levels, glw::GLint layers);
2378         bool SubTestStatus(glw::GLenum attachment, glw::GLenum texture_target, glw::GLuint level, glw::GLint layer,
2379                                            glw::GLuint levels, glw::GLint layers);
2380         bool SubTestContent(glw::GLenum attachment, glw::GLenum texture_target, glw::GLenum internalformat,
2381                                                 glw::GLuint level, glw::GLint layer, glw::GLuint levels, glw::GLint layers);
2382         void            Clear();
2383         glw::GLuint MaxTextureLevels(glw::GLenum texture_target);
2384         glw::GLuint MaxTextureLayers(glw::GLenum texture_target);
2385         void Clean();
2386
2387         /* Private member variables. */
2388         glw::GLuint m_fbo;
2389         glw::GLuint m_to;
2390
2391         /* Static private variables. */
2392         static const glw::GLenum s_targets[];
2393         static const glw::GLuint s_targets_count;
2394
2395         static const glw::GLfloat s_reference_color[4];
2396         static const glw::GLint   s_reference_color_integer[4];
2397         static const glw::GLfloat s_reference_depth;
2398         static const glw::GLint   s_reference_stencil;
2399 };
2400 /* TextureLayerAttachmentTest class */
2401
2402 /** Named Framebuffer Draw Read Buffer
2403  *
2404  *      Create named framebuffer with maximum number of color attachments (use
2405  *      named renderbuffer storage).
2406  *
2407  *      For each color attachment use NamedFramebufferDrawBuffer to set up it as
2408  *      a draw buffer. Clear it with unique color.
2409  *
2410  *      For each color attachment use NamedFramebufferReadBuffer to set up it as
2411  *      a read buffer. Fetch the pixel data and compare that it contains unique
2412  *      color with the attachment was cleared
2413  *
2414  *      Check that NamedFramebufferDrawBuffer and NamedFramebufferReadBuffer
2415  *      accept GL_NONE as mode without error.
2416  *
2417  *      Release all objects.
2418  */
2419 class DrawReadBufferTest : public deqp::TestCase
2420 {
2421 public:
2422         /* Public member functions */
2423         DrawReadBufferTest(deqp::Context& context);
2424
2425         virtual tcu::TestNode::IterateResult iterate();
2426
2427 private:
2428         /* Private member functions */
2429         DrawReadBufferTest(const DrawReadBufferTest& other);
2430         DrawReadBufferTest& operator=(const DrawReadBufferTest& other);
2431 };
2432 /* DrawReadBufferTest class */
2433
2434 /** Named Framebuffer Draw Buffers
2435  *
2436  *      Create named framebuffer with maximum number of color attachments (use
2437  *      named renderbuffer storage).
2438  *
2439  *      Set up all attachments as a draw buffer using the function
2440  *      NamedFramebufferDrawBuffers. Then clear them at once with unique color.
2441  *
2442  *      For each color attachment fetch pixel data and compare that contain
2443  *      the same unique color.
2444  *
2445  *      Release all objects.
2446  */
2447 class DrawBuffersTest : public deqp::TestCase
2448 {
2449 public:
2450         /* Public member functions */
2451         DrawBuffersTest(deqp::Context& context);
2452
2453         virtual tcu::TestNode::IterateResult iterate();
2454
2455 private:
2456         /* Private member functions */
2457         DrawBuffersTest(const DrawBuffersTest& other);
2458         DrawBuffersTest& operator=(const DrawBuffersTest& other);
2459
2460         /* Private static constants. */
2461         static const glw::GLfloat s_rgba[4];
2462 };
2463 /* DrawReadBuffersTest class */
2464
2465 /** Invalidate Named Framebuffer Data
2466  *
2467  *      For default framebuffer try to invalidate each of COLOR, DEPTH, and
2468  *      STENCIL attachments. Expect no error.
2469  *
2470  *      For default framebuffer try to invalidate all (COLOR, DEPTH, and
2471  *      STENCIL) attachments. Expect no error.
2472  *
2473  *      Create named framebuffer with maximum number of color attachments (use
2474  *      named renderbuffer storage), depth attachment and stencil attachment.
2475  *
2476  *      Clear all attachments.
2477  *
2478  *      Try to invalidate content of all attachments using
2479  *      InvalidateNamedFramebufferData. Expect no error.
2480  *
2481  *      Try to invalidate content of each attachment using
2482  *      InvalidateNamedFramebufferData. Expect no error.
2483  *
2484  *      Release all objects.
2485  */
2486 class InvalidateDataTest : public deqp::TestCase
2487 {
2488 public:
2489         /* Public member functions */
2490         InvalidateDataTest(deqp::Context& context);
2491
2492         virtual tcu::TestNode::IterateResult iterate();
2493
2494 private:
2495         /* Private member functions */
2496         InvalidateDataTest(const InvalidateDataTest& other);
2497         InvalidateDataTest& operator=(const InvalidateDataTest& other);
2498
2499         bool CheckErrorAndLog(const glw::GLenum attachment);
2500         bool CheckErrorAndLog(const glw::GLenum attachments[], const glw::GLuint count);
2501 };
2502 /* InvalidateDataTest class */
2503
2504 /** Invalidate Named Framebuffer SubData
2505  *
2506  *      For default framebuffer try to invalidate part of each of COLOR, DEPTH,
2507  *      and STENCIL attachments. Expect no error.
2508  *
2509  *      For default framebuffer try to invalidate part of all (COLOR, DEPTH, and
2510  *      STENCIL) attachments. Expect no error.
2511  *
2512  *      Create named framebuffer with maximum number of color attachments (use
2513  *      named renderbuffer storage), depth attachment and stencil attachment.
2514  *
2515  *      Clear all attachments.
2516  *
2517  *      Try to invalidate content of part of all attachments using
2518  *      InvalidateNamedFramebufferData. Expect no error.
2519  *
2520  *      Try to invalidate content of part of each attachment using
2521  *      InvalidateNamedFramebufferData. Expect no error.
2522  *
2523  *      Release all objects.
2524  */
2525 class InvalidateSubDataTest : public deqp::TestCase
2526 {
2527 public:
2528         /* Public member functions */
2529         InvalidateSubDataTest(deqp::Context& context);
2530
2531         virtual tcu::TestNode::IterateResult iterate();
2532
2533 private:
2534         /* Private member functions */
2535         InvalidateSubDataTest(const InvalidateSubDataTest& other);
2536         InvalidateSubDataTest& operator=(const InvalidateSubDataTest& other);
2537
2538         bool CheckErrorAndLog(const glw::GLenum attachment);
2539         bool CheckErrorAndLog(const glw::GLenum attachments[], const glw::GLuint count);
2540 };
2541 /* InvalidateSubDataTest class */
2542
2543 /** Clear Named Framebuffer
2544  *
2545  *      Repeat following steps for fixed-point, floating-point, signed integer,
2546  *      and unsigned integer color attachments.
2547  *
2548  *          Create named framebuffer with maximum number of color attachments
2549  *          (use named renderbuffer storage).
2550  *
2551  *          Clear each of the color attachment with unique color using proper
2552  *          ClearNamedFramebuffer* function.
2553  *
2554  *          For each color attachment fetch pixel data and compare that contain
2555  *          unique color with which it was cleared.
2556  *
2557  *          Release all objects.
2558  *
2559  *      Next, do following steps:
2560  *
2561  *          Create named framebuffer with depth attachment and stencil
2562  *          attachment.
2563  *
2564  *          Clear each of the attachments with unique value using proper
2565  *          ClearNamedFramebufferfi function.
2566  *
2567  *          Fetch pixel data of each attachment and compare that contain unique
2568  *          value with which it was cleared.
2569  *
2570  *          Release all objects.
2571  */
2572 class ClearTest : public deqp::TestCase
2573 {
2574 public:
2575         /* Public member functions */
2576         ClearTest(deqp::Context& context);
2577
2578         virtual tcu::TestNode::IterateResult iterate();
2579
2580 private:
2581         /* Private member functions */
2582         ClearTest(const ClearTest& other);
2583         ClearTest& operator=(const ClearTest& other);
2584
2585         void PrepareFramebuffer(glw::GLenum buffer, glw::GLenum internalformat);
2586
2587         template <typename T>
2588         bool TestClearColor(glw::GLenum buffer, glw::GLenum attachment, T value);
2589
2590         template <typename T>
2591         bool ClearColor(glw::GLenum buffer, glw::GLint drawbuffer, T value);
2592
2593         bool TestClearDepthAndStencil(glw::GLfloat depth, glw::GLint stencil);
2594
2595         template <typename T>
2596         glw::GLenum Format();
2597
2598         template <typename T>
2599         glw::GLenum Type();
2600
2601         template <typename T>
2602         bool Compare(const T first, const T second);
2603
2604         void Clean();
2605
2606         /* Private member variables. */
2607         glw::GLuint  m_fbo;
2608         glw::GLuint* m_renderbuffers;
2609         glw::GLuint  m_renderbuffers_count;
2610 };
2611 /* ClearTest class */
2612
2613 /** Blit Named Framebuffer
2614  *
2615  *      Create named framebuffer with color, depth and stencil attachments with
2616  *      size 2x2 pixels(use named renderbuffer storage).
2617  *
2618  *      Create named framebuffer with color, depth and stencil attachments with
2619  *      size 2x3 pixels(use named renderbuffer storage).
2620  *
2621  *      Clear the first framebuffer with red color, 0.5 depth and 1 as a stencil
2622  *      index.
2623  *
2624  *      Blit one pixel of the first framebuffer to the second framebuffer to the
2625  *      pixel at (0, 0) position with NEAREST filter.
2626  *
2627  *      Clear first the framebuffer with green color, 0.25 depth and 2 as a
2628  *      stencil index.
2629  *
2630  *      Blit one pixel of the first framebuffer to the second framebuffer to the
2631  *      pixel at (1, 0) position with LINEAR filter for color attachment, but
2632  *      NEAREST filter for depth and stencil attachments.
2633  *
2634  *      Clear the first framebuffer with blue color, 0.125 depth and 3 as a
2635  *      stencil index.
2636  *
2637  *      Blit the whole first framebuffer to the second framebuffer by shrinking
2638  *      it to the single pixel at (2, 0) position.
2639  *
2640  *      Clear the first framebuffer with yellow color, 0.0625 depth and 4 as a
2641  *      stencil index.
2642  *
2643  *      Blit one pixel of the framebuffer to the second framebuffer by expanding
2644  *      it to the three pixel constructing horizontal line at (0, 1) position.
2645  *
2646  *      Expect no error.
2647  *
2648  *      Check that color attachment of the second framebuffer has following
2649  *      values:
2650  *          red,    green,  blue,
2651  *          yellow, yellow, yellow.
2652  *
2653  *      Check that depth attachment of the second framebuffer has following
2654  *      values:
2655  *          0.5,    0.25,   0.125
2656  *          0.0625, 0.0625, 0.0625.
2657  *
2658  *      Check that stencil attachment of the second framebuffer has following
2659  *      values:
2660  *          1,  2,  3
2661  *          4,  4,  4.
2662  *
2663  *      Release all objects.
2664  */
2665 class BlitTest : public deqp::TestCase
2666 {
2667 public:
2668         /* Public member functions */
2669         BlitTest(deqp::Context& context);
2670
2671         virtual tcu::TestNode::IterateResult iterate();
2672
2673 private:
2674         /* Private member functions */
2675         BlitTest(const BlitTest& other);
2676         BlitTest& operator=(const BlitTest& other);
2677
2678         void PrepareFramebuffers();
2679         bool Test();
2680         void ClearFramebuffer(glw::GLfloat red, glw::GLfloat green, glw::GLfloat blue, glw::GLfloat depth,
2681                                                   glw::GLint stencil);
2682         bool CheckErrorAndLog();
2683         bool CheckColor();
2684         bool CheckDepth();
2685         bool CheckStencil();
2686         void Clean();
2687
2688         /* Private member variables. */
2689         glw::GLuint m_fbo_src;
2690         glw::GLuint m_rbo_color_src;
2691         glw::GLuint m_rbo_depth_stencil_src;
2692         glw::GLuint m_fbo_dst;
2693         glw::GLuint m_rbo_color_dst;
2694         glw::GLuint m_rbo_depth_stencil_dst;
2695 };
2696 /* BlitTest class */
2697
2698 /** Check Named Framebuffer Status
2699  *
2700  *      Do following test cases:
2701  *
2702  *          Incomplete attachment case
2703  *
2704  *              Prepare framebuffer with one incomplete attachment.
2705  *
2706  *              Check the framebuffer status using CheckNamedFramebufferStatus.
2707  *              Expect FRAMEBUFFER_INCOMPLETE_ATTACHMENT return value.
2708  *
2709  *              Release all objects.
2710  *
2711  *              Repeat the test case for all possible color, depth and stencil
2712  *              attachments.
2713  *
2714  *          Missing attachment case
2715  *
2716  *              Prepare framebuffer without any attachment.
2717  *
2718  *              Check the framebuffer status using CheckNamedFramebufferStatus.
2719  *              Expect FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT return value.
2720  *
2721  *              Release all objects.
2722  *
2723  *          Incomplete multisample renderbuffer case
2724  *
2725  *              Prepare framebuffer with two multisampled renderbuffer color
2726  *              attachments which have different number of samples.
2727  *
2728  *              Check the framebuffer status using CheckNamedFramebufferStatus.
2729  *              Expect FRAMEBUFFER_INCOMPLETE_MULTISAMPLE return value. If the
2730  *              check fails return TEST_RESULT_COMPATIBILITY_WARNING.
2731  *
2732  *              Release all objects.
2733  *
2734  *          Incomplete multisample texture case
2735  *
2736  *              Prepare framebuffer with two multisampled texture color
2737  *              attachments and one multisampled renderbuffer which all have
2738  *              different number of sample locations. One of the textures shall
2739  *              have fixed sample locations set, one not.
2740  *
2741  *              Check the framebuffer status using CheckNamedFramebufferStatus.
2742  *              Expect FRAMEBUFFER_INCOMPLETE_MULTISAMPLE return value. If the
2743  *              check fails return TEST_RESULT_COMPATIBILITY_WARNING.
2744  *
2745  *              Release all objects.
2746  *
2747  *          Incomplete layer targets case
2748  *
2749  *              Prepare framebuffer with one 3D texture and one 2D texture.
2750  *
2751  *              Check the framebuffer status using CheckNamedFramebufferStatus.
2752  *              Expect FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS return value. If the
2753  *              check fails return TEST_RESULT_COMPATIBILITY_WARNING.
2754  *
2755  *              Release all objects.
2756  *
2757  *      Note
2758  *
2759  *      The specification is not clear about framebuffer completeness. The
2760  *      OpenGL 4.5 Core Profile Specification in chapter 9.4.2 says:
2761  *
2762  *          "The framebuffer object bound to target is said to be framebuffer
2763  *          complete if all the following conditions are true [...]"
2764  *
2765  *      It does not say that framebuffer is incomplete when any of the
2766  *      conditions are not met. Due to this wording, except for obvious cases
2767  *      (incomplete attachment and missing attachments) other tests are optional
2768  *      and may result in QP_TEST_RESULT_COMPATIBILITY_WARNING when fail.
2769  */
2770 class CheckStatusTest : public deqp::TestCase
2771 {
2772 public:
2773         /* Public member functions */
2774         CheckStatusTest(deqp::Context& context);
2775
2776         virtual tcu::TestNode::IterateResult iterate();
2777
2778 private:
2779         /* Private member functions */
2780         CheckStatusTest(const CheckStatusTest& other);
2781         CheckStatusTest& operator=(const CheckStatusTest& other);
2782
2783         bool IncompleteAttachmentTestCase();
2784         bool MissingAttachmentTestCase();
2785         bool IncompleteMultisampleRenderbufferTestCase();
2786         bool IncompleteMultisampleTextureTestCase();
2787         bool IncompleteLayerTargetsTestCase();
2788 };
2789 /* CheckStatusTest class */
2790
2791 /** Get Named Framebuffer Parameters
2792  *
2793  *      Prepare framebuffer with read and write buffers and renderbuffer color
2794  *      attachment.
2795  *
2796  *      Do following checks for the created framebuffer:
2797  *
2798  *          Check that GetNamedFramebufferParameteriv called with parameter name
2799  *          FRAMEBUFFER_DEFAULT_WIDTH returns the value of
2800  *          FRAMEBUFFER_DEFAULT_WIDTH for the framebuffer object.
2801  *
2802  *          Check that GetNamedFramebufferParameteriv called with parameter name
2803  *          FRAMEBUFFER_DEFAULT_HEIGHT returns the value of
2804  *          FRAMEBUFFER_DEFAULT_HEIGHT for the framebuffer object.
2805  *
2806  *          Check that GetNamedFramebufferParameteriv called with parameter name
2807  *          FRAMEBUFFER_DEFAULT_LAYERS returns the value of
2808  *          FRAMEBUFFER_DEFAULT_LAYERS for the framebuffer object.
2809  *          Check that GetNamedFramebufferParameteriv called with parameter name
2810  *          FRAMEBUFFER_DEFAULT_SAMPLES returns the value of
2811  *          FRAMEBUFFER_DEFAULT_SAMPLES for the framebuffer object.
2812  *          Check that GetNamedFramebufferParameteriv called with parameter name
2813  *          FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS returns the boolean value
2814  *          of FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS.
2815  *
2816  *      Do following checks for the created and default (if available)
2817  *      framebuffer:
2818  *
2819  *          Check that GetNamedFramebufferParameteriv called with parameter name
2820  *          DOUBLEBUFFER returns a boolean value indicating whether double
2821  *          buffering is supported for the framebuffer object.
2822  *
2823  *          Check that GetNamedFramebufferParameteriv called with parameter name
2824  *          IMPLEMENTATION_COLOR_READ_FORMAT returns a GLenum value indicating
2825  *          the preferred pixel data format for the framebuffer object.
2826  *
2827  *          Check that GetNamedFramebufferParameteriv called with parameter name
2828  *          IMPLEMENTATION_COLOR_READ_TYPE returns a GLenum value indicating the
2829  *          implementation's preferred pixel data type for the framebuffer
2830  *          object.
2831  *
2832  *          Check that GetNamedFramebufferParameteriv called with parameter name
2833  *          SAMPLES returns an integer value indicating the coverage mask size
2834  *          for the framebuffer object.
2835  *
2836  *          Check that GetNamedFramebufferParameteriv called with parameter name
2837  *          SAMPLE_BUFFERS returns an integer value indicating the number of
2838  *          sample buffers associated with the framebuffer object.
2839  *
2840  *          Check that GetNamedFramebufferParameteriv called with parameter name
2841  *          STEREO returns a boolean value indicating whether stereo buffers
2842  *          (left and right) are supported for the framebuffer object.
2843  *
2844  *      Release all objects.
2845  */
2846 class GetParametersTest : public deqp::TestCase
2847 {
2848 public:
2849         /* Public member functions */
2850         GetParametersTest(deqp::Context& context);
2851
2852         virtual tcu::TestNode::IterateResult iterate();
2853
2854 private:
2855         /* Private member functions */
2856         GetParametersTest(const GetParametersTest& other);
2857         GetParametersTest& operator=(const GetParametersTest& other);
2858
2859         void PrepareFramebuffer();
2860         bool TestDefaultFramebuffer();
2861         bool TestCustomFramebuffer();
2862         void Clean();
2863
2864         /* Private member variables. */
2865         glw::GLuint m_fbo;
2866         glw::GLuint m_rbo;
2867 };
2868 /* GetParametersTest class */
2869
2870 /** Get Named Framebuffer Attachment Parameters
2871  *
2872  *      For default framebuffer, for all attachments:
2873  *          FRONT_LEFT,
2874  *          FRONT_RIGHT,
2875  *          BACK_LEFT,
2876  *          BACK_RIGHT,
2877  *          DEPTH,
2878  *          STENCIL
2879  *      query FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE using
2880  *      GetNamedFramebufferAttachmentParameteriv function. Expect
2881  *      FRAMEBUFFER_DEFAULT return value (as queried with non-DSA way).
2882  *
2883  *      For any attachments not equal to GL_NONE do following queries using
2884  *      GetNamedFramebufferAttachmentParameteriv function:
2885  *          FRAMEBUFFER_ATTACHMENT_RED_SIZE,
2886  *          FRAMEBUFFER_ATTACHMENT_GREEN_SIZE,
2887  *          FRAMEBUFFER_ATTACHMENT_BLUE_SIZE,
2888  *          FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE,
2889  *          FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE,
2890  *          FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE,
2891  *          FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE,
2892  *          FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING.
2893  *      Expect value equal to framebuffers setup (as queried with non-DSA way).
2894  *      Expect no error.
2895  *
2896  *      Create 3 framebuffer objects with renderbuffer color attachment, and
2897  *      depth or stencil or depth-stencil attachments.
2898  *
2899  *      For each of framebuffers, for each of following attachments:
2900  *          DEPTH_ATTACHMENT,
2901  *          STENCIL_ATTACHMENT,
2902  *          DEPTH_STENCIL_ATTACHMENT,
2903  *          COLOR_ATTACHMENT0,
2904  *          COLOR_ATTACHMENT1
2905  *      query FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE using
2906  *      GetNamedFramebufferAttachmentParameteriv function. Expect the same
2907  *      return value as queried with non-DSA way.
2908  *
2909  *      For each of framebuffers, for any attachments not equal to GL_NONE do
2910  *      following queries using GetNamedFramebufferAttachmentParameteriv
2911  *      function:
2912  *          FRAMEBUFFER_ATTACHMENT_OBJECT_NAME,
2913  *          FRAMEBUFFER_ATTACHMENT_RED_SIZE,
2914  *          FRAMEBUFFER_ATTACHMENT_GREEN_SIZE,
2915  *          FRAMEBUFFER_ATTACHMENT_BLUE_SIZE,
2916  *          FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE,
2917  *          FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE,
2918  *          FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE,
2919  *          FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE,
2920  *          FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING
2921  *      Expect value equal to framebuffers setup (as queried with non-DSA way).
2922  *      Expect no error.
2923  *
2924  *      Release objects.
2925  *
2926  *      Create 3 framebuffer objects with texture color attachment, and
2927  *      depth or stencil or depth-stencil attachments.
2928  *
2929  *      For each of framebuffers, for each of following attachments:
2930  *          DEPTH_ATTACHMENT,
2931  *          STENCIL_ATTACHMENT,
2932  *          DEPTH_STENCIL_ATTACHMENT,
2933  *          COLOR_ATTACHMENT0,
2934  *          COLOR_ATTACHMENT1
2935  *      query FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE using
2936  *      GetNamedFramebufferAttachmentParameteriv function. Expect the same
2937  *      return value as queried with non-DSA way.
2938  *
2939  *      For each of framebuffers, for any attachments not equal to GL_NONE do
2940  *      following queries using GetNamedFramebufferAttachmentParameteriv
2941  *      function:
2942  *          FRAMEBUFFER_ATTACHMENT_OBJECT_NAME,
2943  *          FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL,
2944  *          FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE,
2945  *          FRAMEBUFFER_ATTACHMENT_LAYERED,
2946  *          FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER,
2947  *          FRAMEBUFFER_ATTACHMENT_RED_SIZE,
2948  *          FRAMEBUFFER_ATTACHMENT_GREEN_SIZE,
2949  *          FRAMEBUFFER_ATTACHMENT_BLUE_SIZE,
2950  *          FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE,
2951  *          FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE,
2952  *          FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE,
2953  *          FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE,
2954  *          FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING
2955  *      Expect value equal to framebuffers setup (as queried with non-DSA way).
2956  *      Expect no error.
2957  *
2958  *      Release objects.
2959  *
2960  *      Additional conditions:
2961  *
2962  *          Do not query DEPTH_STENCIL_ATTACHMENT attachment if the renderbuffer
2963  *          or texture is not depth-stencil.
2964  *
2965  *          Do not query FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE pname with
2966  *          DEPTH_STENCIL_ATTACHMENT attachment.
2967  */
2968 class GetAttachmentParametersTest : public deqp::TestCase
2969 {
2970 public:
2971         /* Public member functions */
2972         GetAttachmentParametersTest(deqp::Context& context);
2973
2974         virtual tcu::TestNode::IterateResult iterate();
2975
2976 private:
2977         /* Private member functions */
2978         GetAttachmentParametersTest(const GetAttachmentParametersTest& other);
2979         GetAttachmentParametersTest& operator=(const GetAttachmentParametersTest& other);
2980
2981         void CreateRenderbufferFramebuffer(bool depth, bool stencil);
2982         void CreateTextureFramebuffer(bool depth, bool stencil);
2983         bool TestDefaultFramebuffer();
2984         bool TestRenderbufferFramebuffer(bool depth_stencil);
2985         bool TestTextureFramebuffer(bool depth_stencil);
2986         void Clean();
2987
2988         /* Private member variables. */
2989         glw::GLuint m_fbo;
2990         glw::GLuint m_rbo[2];
2991         glw::GLuint m_to[2];
2992 };
2993 /* GetParametersTest class */
2994
2995 /** Create Named Framebuffers Errors
2996  *
2997  *      Check that INVALID_VALUE is generated by CreateFramebuffers if n is
2998  *      negative.
2999  */
3000 class CreationErrorsTest : public deqp::TestCase
3001 {
3002 public:
3003         /* Public member functions */
3004         CreationErrorsTest(deqp::Context& context);
3005
3006         virtual tcu::TestNode::IterateResult iterate();
3007
3008 private:
3009         /* Private member functions */
3010         CreationErrorsTest(const CreationErrorsTest& other);
3011         CreationErrorsTest& operator=(const CreationErrorsTest& other);
3012 };
3013 /* CreationErrorsTest class */
3014
3015 /** Named Framebuffer Renderbuffer Errors
3016  *
3017  *      Check that INVALID_OPERATION is generated by
3018  *      NamedFramebufferRenderbuffer if framebuffer is not the name of an
3019  *      existing framebuffer object.
3020  *
3021  *      Check that INVALID_OPERATION is generated by NamedFramebufferRenderbuffer
3022  *      if attachment is COLOR_ATTACHMENTm where m is greater than or equal to
3023  *      the value of MAX_COLOR_ATTACHMENTS.
3024  *
3025  *      Check that INVALID_ENUM is generated by NamedFramebufferRenderbuffer if
3026  *      attachment is not one of the attachments in table 9.2, and attachment is
3027  *      not COLOR_ATTACHMENTm where m is greater than or equal to the value of
3028  *      MAX_COLOR_ATTACHMENTS.
3029  *
3030  *      Check that INVALID_ENUM is generated by NamedFramebufferRenderbuffer if
3031  *      renderbuffer target is not RENDERBUFFER.
3032  *
3033  *      Check that INVALID_OPERATION is generated by
3034  *      NamedFramebufferRenderbuffer if renderbuffer target is not zero or the
3035  *      name of an existing renderbuffer object of type RENDERBUFFER.
3036  */
3037 class RenderbufferAttachmentErrorsTest : public deqp::TestCase
3038 {
3039 public:
3040         /* Public member functions */
3041         RenderbufferAttachmentErrorsTest(deqp::Context& context);
3042
3043         virtual tcu::TestNode::IterateResult iterate();
3044
3045 private:
3046         /* Private member functions */
3047         RenderbufferAttachmentErrorsTest(const RenderbufferAttachmentErrorsTest& other);
3048         RenderbufferAttachmentErrorsTest& operator=(const RenderbufferAttachmentErrorsTest& other);
3049
3050         void PrepareObjects();
3051         bool ExpectError(glw::GLenum expected_error, bool framebuffer, bool attachment, bool color_attachment,
3052                                          bool renderbuffertarget, bool renderbuffer);
3053         void Clean();
3054
3055         /* Private member variables. */
3056         glw::GLuint m_fbo_valid;
3057         glw::GLuint m_rbo_valid;
3058         glw::GLuint m_fbo_invalid;
3059         glw::GLuint m_rbo_invalid;
3060         glw::GLenum m_color_attachment_invalid;
3061         glw::GLenum m_attachment_invalid;
3062         glw::GLenum m_renderbuffer_target_invalid;
3063 };
3064 /* RenderbufferAttachmentErrorsTest class */
3065
3066 /** Named Framebuffer Texture Errors
3067  *
3068  *      Check that GL_INVALID_OPERATION is generated by glNamedFramebufferTexture and glNamedFramebufferTextureLayer
3069  *      if framebuffer is not the name of an existing framebuffer object.
3070  *
3071  *      Check that INVALID_OPERATION is generated by glNamedFramebufferTexture and glNamedFramebufferTextureLayer
3072  *      if attachment is COLOR_ATTACHMENTm where m is greater than or equal to
3073  *      the value of MAX_COLOR_ATTACHMENTS.
3074  *
3075  *      Check that INVALID_ENUM is generated by glNamedFramebufferTexture and glNamedFramebufferTextureLayer if
3076  *      attachment is not one of the attachments in table 9.2, and attachment is
3077  *      not COLOR_ATTACHMENTm where m is greater than or equal to the value of
3078  *      MAX_COLOR_ATTACHMENTS.
3079  *
3080  *      Check that INVALID_VALUE is generated by glNamedFramebufferTexture if texture is not zero or the name
3081  *      of an existing texture object.
3082  *
3083  *      Check that INVALID_OPERATION is generated by glNamedFramebufferTextureLayer if texture is not zero or
3084  *      the name of an existing texture object.
3085  *
3086  *      Check that INVALID_VALUE is generated by glNamedFramebufferTexture and glNamedFramebufferTextureLayer if
3087  *      texture is not zero and level is not a supported texture level for
3088  *      texture.
3089  *
3090  *      Check that INVALID_OPERATION is generated by glNamedFramebufferTexture and glNamedFramebufferTextureLayer
3091  *      if texture is a buffer texture.
3092  *
3093  *      Check that INVALID_VALUE error is generated by NamedFramebufferTextureLayer if texture is a three-dimensional
3094  *      texture, and layer is larger than the value of MAX_3D_TEXTURE_SIZE minus one.
3095  *
3096  *      Check that INVALID_VALUE error is generated by NamedFramebufferTextureLayer if texture is an array texture,
3097  *      and layer is larger than the value of MAX_ARRAY_TEXTURE_LAYERS minus one.
3098  *
3099  *      Check that INVALID_VALUE error is generated by NamedFramebufferTextureLayer if texture is a cube map array texture,
3100  *      and (layer / 6) is larger than the value of MAX_CUBE_MAP_TEXTURE_SIZE minus one (see section 9.8).
3101  *      Check that INVALID_VALUE error is generated by NamedFramebufferTextureLayer if texture is non-zero
3102  *      and layer is negative.
3103  *
3104  *      Check that INVALID_OPERATION error is generated by NamedFramebufferTextureLayer if texture is non-zero
3105  *      and is not the name of a three-dimensional, two-dimensional multisample array, one- or two-dimensional array,
3106  *      or cube map array texture.
3107  */
3108 class TextureAttachmentErrorsTest : public deqp::TestCase
3109 {
3110 public:
3111         /* Public member functions */
3112         TextureAttachmentErrorsTest(deqp::Context& context);
3113
3114         virtual tcu::TestNode::IterateResult iterate();
3115
3116 private:
3117         /* Private member functions */
3118         TextureAttachmentErrorsTest(const TextureAttachmentErrorsTest& other);
3119         TextureAttachmentErrorsTest& operator=(const TextureAttachmentErrorsTest& other);
3120
3121         void PrepareObjects();
3122         bool ExpectError(glw::GLenum expected_error, const glw::GLchar* function_name, bool framebuffer, bool attachment,
3123                                          bool color_attachment, bool texture, bool level, const glw::GLchar* texture_type, bool layer);
3124         void Clean();
3125
3126         /* Private member variables. */
3127         glw::GLuint m_fbo_valid;
3128         glw::GLuint m_to_valid;
3129         glw::GLuint m_to_3d_valid;
3130         glw::GLuint m_to_array_valid;
3131         glw::GLuint m_to_cubearray_valid;
3132         glw::GLuint m_tbo_valid;
3133         glw::GLuint m_fbo_invalid;
3134         glw::GLuint m_to_invalid;
3135         glw::GLuint m_to_layer_invalid; /* it is valid rectangle texture, but invalid for NamedFramebufferTextureLayer */
3136         glw::GLenum m_color_attachment_invalid;
3137         glw::GLenum m_attachment_invalid;
3138         glw::GLint  m_level_invalid;
3139         glw::GLint  m_max_3d_texture_size;
3140         glw::GLint  m_max_3d_texture_depth;
3141         glw::GLint  m_max_array_texture_layers;
3142         glw::GLint  m_max_cube_map_texture_size;
3143 };
3144 /* TextureAttachmentErrorsTest class */
3145
3146 /** Named Framebuffer Draw Read Buffers Errors
3147  *
3148  *      Check that INVALID_OPERATION error is generated by
3149  *      NamedFramebufferDrawBuffer if framebuffer is not zero or the name of an
3150  *      existing framebuffer object.
3151  *
3152  *      Check that INVALID_ENUM is generated by NamedFramebufferDrawBuffer if
3153  *      buf is not an accepted value.
3154  *
3155  *      Check that INVALID_OPERATION is generated by NamedFramebufferDrawBuffer
3156  *      if the GL is bound to a draw framebuffer object and the ith argument is
3157  *      a value other than COLOR_ATTACHMENTi or NONE.
3158  *
3159  *      Check that INVALID_OPERATION error is generated by
3160  *      NamedFramebufferDrawBuffers if framebuffer is not zero or the name of an
3161  *      existing framebuffer object.
3162  *
3163  *      Check that INVALID_VALUE is generated by NamedFramebufferDrawBuffers if
3164  *      n is less than 0.
3165  *
3166  *      Check that INVALID_VALUE is generated by NamedFramebufferDrawBuffers if
3167  *      n is greater than MAX_DRAW_BUFFERS.
3168  *
3169  *      Check that INVALID_ENUM is generated by NamedFramebufferDrawBuffers if
3170  *      one of the values in bufs is not an accepted value.
3171  *
3172  *      Check that INVALID_OPERATION is generated by NamedFramebufferDrawBuffers
3173  *      if a symbolic constant other than GL_NONE appears more than once in
3174  *      bufs.
3175  *
3176  *      Check that INVALID_ENUM error is generated by
3177  *      NamedFramebufferDrawBuffers if any value in bufs is FRONT, LEFT, RIGHT,
3178  *      or FRONT_AND_BACK. This restriction applies to both the default
3179  *      framebuffer and framebuffer objects, and exists because these constants
3180  *      may themselves refer to multiple buffers, as shown in table 17.4.
3181  *
3182  *      Check that INVALID_OPERATION is generated by NamedFramebufferDrawBuffers
3183  *      if any value in bufs is BACK, and n is not one.
3184  *
3185  *      Check that INVALID_OPERATION is generated by NamedFramebufferDrawBuffers
3186  *      if the API call refers to a framebuffer object and one or more of the
3187  *      values in bufs is anything other than NONE or one of the
3188  *      COLOR_ATTACHMENTn tokens.
3189  *
3190  *      Check that INVALID_OPERATION is generated by NamedFramebufferDrawBuffers
3191  *      if the API call refers to the default framebuffer and one or more of the
3192  *      values in bufs is one of the COLOR_ATTACHMENTn tokens.
3193  *
3194  *      Check that INVALID_OPERATION is generated by NamedFramebufferReadBuffer
3195  *      if framebuffer is not zero or the name of an existing framebuffer
3196  *      object.
3197  *
3198  *      Check that INVALID_ENUM is generated by NamedFramebufferReadBuffer if
3199  *      src is not one of the accepted values (tables 17.4 and 17.5 of OpenGL
3200  *      4.5 Core Profile Specification).
3201  *
3202  *      Check that INVALID_OPERATION is generated by NamedFramebufferReadBuffer
3203  *      if the default framebuffer is affected and src is a value (other than
3204  *      NONE) that does not indicate any of the color buffers allocated to the
3205  *      default framebuffer.
3206  *
3207  *      Check that INVALID_OPERATION is generated by NamedFramebufferReadBuffer
3208  *      if a framebuffer object is affected, and src is one of the  constants
3209  *      from table 17.4 (other than NONE, or COLOR_ATTACHMENTm where m is
3210  *      greater than or equal to the value of MAX_COLOR_ATTACHMENTS).
3211  */
3212 class DrawReadBuffersErrorsTest : public deqp::TestCase
3213 {
3214 public:
3215         /* Public member functions */
3216         DrawReadBuffersErrorsTest(deqp::Context& context);
3217
3218         virtual tcu::TestNode::IterateResult iterate();
3219
3220 private:
3221         /* Private member functions */
3222         DrawReadBuffersErrorsTest(const DrawReadBuffersErrorsTest& other);
3223         DrawReadBuffersErrorsTest operator=(const DrawReadBuffersErrorsTest& other);
3224
3225         void PrepareObjects();
3226         bool ExpectError(glw::GLenum expected_error, const glw::GLchar* function, const glw::GLchar* conditions);
3227         void Clean();
3228
3229         /* Private member variables. */
3230         glw::GLuint  m_fbo_valid;
3231         glw::GLuint  m_fbo_invalid;
3232         glw::GLenum  m_attachment_color;
3233         glw::GLenum  m_attachment_back_left;
3234         glw::GLenum  m_attachment_right;
3235         glw::GLenum  m_attachment_left;
3236         glw::GLenum  m_attachment_front;
3237         glw::GLenum  m_attachment_front_and_back;
3238         glw::GLenum  m_attachment_back;
3239         glw::GLenum  m_attachment_invalid;
3240         glw::GLenum  m_attachments_invalid[2];
3241         glw::GLenum  m_attachments_back_invalid[2];
3242         glw::GLint   m_attachments_too_many_count;
3243         glw::GLenum* m_attachments_too_many;
3244         glw::GLint   m_max_color_attachments;
3245 };
3246 /* DrawReadBuffersErrorsTest class */
3247
3248 /** Invalidate Framebuffer Data and SubData Errors
3249
3250  Check that INVALID_OPERATION error is generated by
3251  InvalidateNamedFramebufferData if framebuffer is not zero or the name of
3252  an existing framebuffer object.
3253
3254  Check that INVALID_ENUM error is generated by
3255  InvalidateNamedFramebufferData if a framebuffer object is affected, and
3256  any element of of attachments is not one of the values
3257  {COLOR_ATTACHMENTi, DEPTH_ATTACHMENT, STENCIL_ATTACHMENT,
3258  DEPTH_STENCIL_ATTACHMENT}.
3259
3260  Check that INVALID_OPERATION error is generated by
3261  InvalidateNamedFramebufferData if attachments contains COLOR_ATTACHMENTm
3262  where m is greater than or equal to the value of MAX_COLOR_ATTACHMENTS.
3263
3264  Check that INVALID_ENUM error is generated by
3265  InvalidateNamedFramebufferData if the default framebuffer is affected,
3266  and any elements of attachments are not one of:
3267  -  FRONT_LEFT, FRONT_RIGHT, BACK_LEFT, and BACK_RIGHT, identifying that
3268  specific buffer,
3269  -  COLOR, which is treated as BACK_LEFT for a double-buffered context
3270  and FRONT_LEFT for a single-buffered context,
3271  -  DEPTH, identifying the depth buffer,
3272  -  STENCIL, identifying the stencil buffer.
3273
3274  Check that INVALID_OPERATION error is generated by
3275  InvalidateNamedSubFramebuffer if framebuffer is not zero or the name of
3276  an existing framebuffer object.
3277
3278  Check that INVALID_VALUE error is generated by
3279  InvalidateNamedSubFramebuffer if numAttachments, width, or height is
3280  negative.
3281
3282  Check that INVALID_ENUM error is generated by
3283  InvalidateNamedSubFramebuffer if a framebuffer object is affected, and
3284  any element of attachments is not one of the values {COLOR_ATTACHMENTi,
3285  DEPTH_ATTACHMENT, STENCIL_ATTACHMENT, DEPTH_STENCIL_ATTACHMENT}.
3286
3287  Check that INVALID_OPERATION error is generated by
3288  InvalidateNamedSubFramebuffer if attachments contains COLOR_ATTACHMENTm
3289  where m is greater than or equal to the value of MAX_COLOR_ATTACHMENTS.
3290
3291  Check that INVALID_ENUM error is generated by
3292  InvalidateNamedSubFramebuffer if the default framebuffer is affected,
3293  and any elements of attachments are not one of:
3294  -  FRONT_LEFT, FRONT_RIGHT, BACK_LEFT, and BACK_RIGHT, identifying that
3295  specific buffer,
3296  -  COLOR, which is treated as BACK_LEFT for a double-buffered context
3297  and FRONT_LEFT for a single-buffered context,
3298  -  DEPTH, identifying the depth buffer,
3299  -  STENCIL, identifying the stencil buffer.
3300  */
3301 class InvalidateDataAndSubDataErrorsTest : public deqp::TestCase
3302 {
3303 public:
3304         /* Public member functions */
3305         InvalidateDataAndSubDataErrorsTest(deqp::Context& context);
3306
3307         virtual tcu::TestNode::IterateResult iterate();
3308
3309 private:
3310         /* Private member functions */
3311         InvalidateDataAndSubDataErrorsTest(const InvalidateDataAndSubDataErrorsTest& other);
3312         InvalidateDataAndSubDataErrorsTest operator=(const InvalidateDataAndSubDataErrorsTest& other);
3313
3314         void PrepareObjects();
3315         bool ExpectError(glw::GLenum expected_error, const glw::GLchar* function, const glw::GLchar* conditions);
3316         void Clean();
3317
3318         /* Private member variables. */
3319         glw::GLuint m_fbo_valid;
3320         glw::GLuint m_rbo;
3321         glw::GLuint m_fbo_invalid;
3322         glw::GLenum m_fbo_attachment_valid;
3323         glw::GLenum m_fbo_attachment_invalid;
3324         glw::GLenum m_color_attachment_invalid;
3325         glw::GLenum m_default_attachment_invalid;
3326 };
3327 /* InvalidateDataAndSubDataErrorsTest class */
3328
3329 /** Clear Named Framebuffer Errors
3330  *
3331  *      Check that INVALID_OPERATION is generated by ClearNamedFramebuffer* if
3332  *      framebuffer is not zero or the name of an existing framebuffer object.
3333  *
3334  *      Check that INVALID_ENUM is generated by ClearNamedFramebufferiv buffer
3335  *      is not COLOR or STENCIL.
3336  *
3337  *      Check that INVALID_ENUM is generated by ClearNamedFramebufferuiv buffer
3338  *      is not COLOR.
3339  *
3340  *      Check that INVALID_ENUM is generated by ClearNamedFramebufferfv buffer
3341  *      is not COLOR or DEPTH.
3342  *
3343  *      Check that INVALID_ENUM is generated by ClearNamedFramebufferfi buffer
3344  *      is not DEPTH_STENCIL.
3345  *
3346  *      Check that INVALID_VALUE is generated if buffer is COLOR drawbuffer is
3347  *      negative, or greater than the value of MAX_DRAW_BUFFERS minus one.
3348  *
3349  *      Check that INVALID_VALUE is generated if buffer is DEPTH, STENCIL or
3350  *      DEPTH_STENCIL and drawbuffer is not zero.
3351  */
3352 class ClearNamedFramebufferErrorsTest : public deqp::TestCase
3353 {
3354 public:
3355         /* Public member functions */
3356         ClearNamedFramebufferErrorsTest(deqp::Context& context);
3357
3358         virtual tcu::TestNode::IterateResult iterate();
3359
3360 private:
3361         /* Private member functions */
3362         ClearNamedFramebufferErrorsTest(const ClearNamedFramebufferErrorsTest& other);
3363         ClearNamedFramebufferErrorsTest& operator=(const ClearNamedFramebufferErrorsTest& other);
3364
3365         void PrepareObjects();
3366         bool ExpectError(glw::GLenum expected_error, const glw::GLchar* function, const glw::GLchar* conditions);
3367         void Clean();
3368
3369         /* Private member variables. */
3370         glw::GLuint m_fbo_valid;
3371         glw::GLuint m_rbo_color;
3372         glw::GLuint m_rbo_depth_stencil;
3373         glw::GLuint m_fbo_invalid;
3374 };
3375 /* ClearNamedFramebufferErrorsTest class */
3376
3377 /** Check Named Framebuffer Status Errors
3378  *
3379  *      Check that INVALID_ENUM is generated by CheckNamedFramebufferStatus if
3380  *      target is not DRAW_FRAMEBUFFER, READ_FRAMEBUFFER or FRAMEBUFFER.
3381  *
3382  *      Check that INVALID_OPERATION is generated by CheckNamedFramebufferStatus
3383  *      if framebuffer is not zero or the name of an existing framebuffer
3384  *      object.
3385  */
3386 class CheckStatusErrorsTest : public deqp::TestCase
3387 {
3388 public:
3389         /* Public member functions */
3390         CheckStatusErrorsTest(deqp::Context& context);
3391
3392         virtual tcu::TestNode::IterateResult iterate();
3393
3394 private:
3395         /* Private member functions */
3396         CheckStatusErrorsTest(const CheckStatusErrorsTest& other);
3397         CheckStatusErrorsTest& operator=(const CheckStatusErrorsTest& other);
3398
3399         void PrepareObjects();
3400         bool ExpectError(glw::GLenum expected_error, const glw::GLchar* function, const glw::GLchar* conditions);
3401         void Clean();
3402
3403         /* Private member variables. */
3404         glw::GLuint m_fbo_valid;
3405         glw::GLuint m_fbo_invalid;
3406         glw::GLuint m_target_invalid;
3407 };
3408 /* CheckStatusErrorsTest class */
3409
3410 /** Get Named Framebuffer Parameter Errors
3411  *
3412  *      Check that INVALID_OPERATION is generated by
3413  *      GetNamedFramebufferParameteriv if framebuffer is not zero or the name of
3414  *      an existing framebuffer object.
3415  *
3416  *      Check that INVALID_ENUM is generated by GetNamedFramebufferParameteriv
3417  *      if pname is not one of the accepted parameter names.
3418  *
3419  *      Check that INVALID_OPERATION is generated if a default framebuffer is
3420  *      queried, and pname is not one of DOUBLEBUFFER,
3421  *      IMPLEMENTATION_COLOR_READ_FORMAT, IMPLEMENTATION_COLOR_READ_TYPE,
3422  *      SAMPLES, SAMPLE_BUFFERS or STEREO.
3423  */
3424 class GetParameterErrorsTest : public deqp::TestCase
3425 {
3426 public:
3427         /* Public member functions */
3428         GetParameterErrorsTest(deqp::Context& context);
3429
3430         virtual tcu::TestNode::IterateResult iterate();
3431
3432 private:
3433         /* Private member functions */
3434         GetParameterErrorsTest(const GetParameterErrorsTest& other);
3435         GetParameterErrorsTest& operator=(const GetParameterErrorsTest& other);
3436
3437         void PrepareObjects();
3438         bool ExpectError(glw::GLenum expected_error, const glw::GLchar* function, const glw::GLchar* conditions);
3439         void Clean();
3440
3441         /* Private member variables. */
3442         glw::GLuint m_fbo_valid;
3443         glw::GLuint m_fbo_invalid;
3444         glw::GLuint m_parameter_invalid;
3445 };
3446 /* GetParameterErrorsTest class */
3447
3448 /** Get Named Framebuffer Attachment Parameter Errors
3449  *
3450  *      Check that GL_INVALID_OPERATION is generated by
3451  *      GetNamedFramebufferAttachmentParameteriv if framebuffer is not zero or
3452  *      the name of an existing framebuffer object.
3453  *
3454  *      Check that INVALID_ENUM is generated by
3455  *      GetNamedFramebufferAttachmentParameteriv if pname is not valid for the
3456  *      value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, as described above.
3457  *
3458  *      Check that INVALID_ENUM error is generated if a framebuffer object is queried, attachment
3459  *      is not one of the attachments in table 9.2 (COLOR_ATTACHMENTi, DEPTH_ATTACHMENT, STENCIL_ATTACHMENT, DEPTH_STENCIL_ATTACHMENT), and attachment is not
3460  *      COLOR_ATTACHMENTm where m is greater than or equal to the value of MAX_COLOR_ATTACHMENTS.
3461  *
3462  *      Check that INVALID_OPERATION is generated by
3463  *      GetNamedFramebufferAttachmentParameteriv if the value of
3464  *      FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE is GL_NONE and pname is not
3465  *      FRAMEBUFFER_ATTACHMENT_OBJECT_NAME or
3466  *      FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE.
3467  *
3468  *      Check that INVALID_OPERATION is generated by
3469  *      GetNamedFramebufferAttachmentParameteriv if attachment is
3470  *      DEPTH_STENCIL_ATTACHMENT and pname is
3471  *      FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE.
3472  *
3473  *      Check that an INVALID_ENUM error is generated if the default framebuffer is
3474  *      queried and attachment is not one the values specified in table 9.1.
3475  *
3476  *      Check that an INVALID_OPERATION error is generated if a framebuffer object is
3477  *      bound to target and attachment is COLOR_ATTACHMENTm where m is greater than or
3478  *      equal to the value of MAX_COLOR_ATTACHMENTS.
3479  *
3480  *      Check that an INVALID_ENUM error is generated if a framebuffer object is
3481  *      queried, attachment is not one of the attachments in table 9.2, and attachment
3482  *      is not COLOR_ATTACHMENTm where m is greater than or equal to the value of
3483  *      MAX_COLOR_ATTACHMENTS.
3484  */
3485 class GetAttachmentParameterErrorsTest : public deqp::TestCase
3486 {
3487 public:
3488         /* Public member functions */
3489         GetAttachmentParameterErrorsTest(deqp::Context& context);
3490
3491         virtual tcu::TestNode::IterateResult iterate();
3492
3493 private:
3494         /* Private member functions */
3495         GetAttachmentParameterErrorsTest(const GetAttachmentParameterErrorsTest& other);
3496         GetAttachmentParameterErrorsTest& operator=(const GetAttachmentParameterErrorsTest& other);
3497
3498         void PrepareObjects();
3499         bool ExpectError(glw::GLenum expected_error, const glw::GLchar* function, const glw::GLchar* conditions);
3500         void Clean();
3501
3502         /* Private member variables. */
3503         glw::GLuint m_fbo_valid;
3504         glw::GLuint m_rbo_color;
3505         glw::GLuint m_rbo_depth_stencil;
3506         glw::GLuint m_fbo_invalid;
3507         glw::GLuint m_parameter_invalid;
3508         glw::GLenum m_attachment_invalid;
3509         glw::GLenum m_default_attachment_invalid;
3510         glw::GLint  m_max_color_attachments;
3511 };
3512 /* GetAttachmentParameterErrorsTest class */
3513
3514 /** Framebuffer and Renderbuffer Functional
3515  *
3516  *      Create two framebuffer objects using CreateFramebuffers.
3517  *
3518  *      Setup first framebuffer with renderbuffer color, depth and stencil
3519  *      attachments. Setup storage size with width and height equal to 8. Set
3520  *      them as draw and read buffers. Clean up it, use black color. Check the
3521  *      framebuffer status.
3522  *
3523  *      Setup second framebuffer with texture color attachment. Setup storage
3524  *      size with width equal to 4 and height equal to 3.  Check the framebuffer
3525  *      status.
3526  *
3527  *      Prepare GLSL program which can draw triangles using orthographic
3528  *      projection. Fragment shader
3529  *
3530  *      Clean both framebuffers using ClearNamedFramebuffer* functions.
3531  *
3532  *      Use first framebuffer.
3533  *
3534  *      Draw to stencil a quad with screen positions [-0.5, -0.5], [-0.5, 0.5],
3535  *      [0.5, -0.5] and [0.5, 0.5].
3536  *
3537  *      Draw to depth buffer a quad with positions [-1, -1, -1], [-1, 1, -1],
3538  *      [1, -1, 0] and [1, 1, 0].
3539  *
3540  *      Turn on depth and stencil tests. Depth test shall pass if incoming depth
3541  *      value is LESS than stored. The Stencil test shall pass only for any
3542  *      stencil pass.
3543  *
3544  *      Draw Full screen quad to draw buffer with z = 0.5.
3545  *
3546  *      Blit the color content of the first framebuffer to the second with
3547  *      nearest filter.
3548  *
3549  *      Fetch data. Expect that second framebuffer contain following data
3550  *          black,  black,  black,  black,
3551  *          black,  black,  white,  black,
3552  *          black,  black,  black,  black.
3553  */
3554 class FunctionalTest : public deqp::TestCase
3555 {
3556 public:
3557         /* Public member functions */
3558         FunctionalTest(deqp::Context& context);
3559
3560         virtual tcu::TestNode::IterateResult iterate();
3561
3562 private:
3563         /* Private member functions */
3564         FunctionalTest(const FunctionalTest& other);
3565         FunctionalTest& operator=(const FunctionalTest& other);
3566
3567         bool PrepareFirstFramebuffer();
3568         bool PrepareSecondFramebuffer();
3569         bool ClearFramebuffers();
3570         void PrepareProgram();
3571         void PrepareBuffersAndVertexArrays();
3572         bool DrawAndBlit();
3573         bool CheckSecondFramebufferContent();
3574         void Clean();
3575
3576         /* Private member variables. */
3577         glw::GLuint m_fbo_1st;
3578         glw::GLuint m_fbo_2nd;
3579         glw::GLuint m_rbo_color;
3580         glw::GLuint m_rbo_depth_stencil;
3581         glw::GLuint m_to_color;
3582         glw::GLuint m_po;
3583         glw::GLuint m_vao_stencil_pass_quad;
3584         glw::GLuint m_vao_depth_pass_quad;
3585         glw::GLuint m_vao_color_pass_quad;
3586         glw::GLuint m_bo_stencil_pass_quad;
3587         glw::GLuint m_bo_depth_pass_quad;
3588         glw::GLuint m_bo_color_pass_quad;
3589
3590         /* Private static variables. */
3591         static const glw::GLchar  s_vertex_shader[];
3592         static const glw::GLchar  s_fragment_shader[];
3593         static const glw::GLchar  s_attribute[];
3594         static const glw::GLfloat s_stencil_pass_quad[];
3595         static const glw::GLfloat s_depth_pass_quad[];
3596         static const glw::GLfloat s_color_pass_quad[];
3597         static const glw::GLuint  s_stencil_pass_quad_size;
3598         static const glw::GLuint  s_depth_pass_quad_size;
3599         static const glw::GLuint  s_color_pass_quad_size;
3600 };
3601 /* FunctionalTest class */
3602 } /* Framebuffers namespace */
3603
3604 namespace Renderbuffers
3605 {
3606 /** Renderbuffer Creation
3607  *
3608  *      Create at least two renderbuffer objects using GenRenderbuffers
3609  *      function. Check them without binding, using IsRenderbuffer function.
3610  *      Expect FALSE.
3611  *
3612  *      Create at least two renderbuffer objects using CreateRenderbuffers
3613  *      function. Check them without binding, using IsRenderbuffer function.
3614  *      Expect TRUE.
3615  *
3616  *      Release objects.
3617  */
3618 class CreationTest : public deqp::TestCase
3619 {
3620 public:
3621         /* Public member functions */
3622         CreationTest(deqp::Context& context);
3623
3624         virtual tcu::TestNode::IterateResult iterate();
3625
3626 private:
3627         /* Private member functions */
3628         CreationTest(const CreationTest& other);
3629         CreationTest& operator=(const CreationTest& other);
3630 };
3631 /* CreationTest class */
3632
3633 /** Named Renderbuffer Storage
3634  *
3635  *      Create renderbuffer object. Prepare its storage using
3636  *      NamedRenderbufferStorage function.
3637  *
3638  *      Create framebuffer object. Attach renderbuffer to proper attachment
3639  *      point.
3640  *
3641  *      Clear framebuffer's renderbuffer attachment with reference value. Fetch
3642  *      the data from framebuffer's attachment using ReadPixels. Compare the
3643  *      fetched values with the reference.
3644  *
3645  *      Release all objects.
3646  *
3647  *      Repeat the test for following internal formats:
3648  *
3649  *          R8, R16, RG8, RG16, RGB565, RGBA4, RGB5_A1, RGBA8, RGB10_A2,
3650  *          RGB10_A2UI, RGBA16, SRGB8_ALPHA8, R16F, RG16F, RGBA16F, R32F, RG32F,
3651  *          RGBA32F, R11F_G11F_B10F, R8I, R8UI, R16I, R16UI, R32I, R32UI, RG8I,
3652  *          RG8UI, RG16I, RG16UI, RG32I, RG32UI, RGBA8I, RGBA8UI, RGBA16I,
3653  *          RGBA16UI, RGBA32I, RGBA32UI, DEPTH_COMPONENT16, DEPTH_COMPONENT24,
3654  *          DEPTH_COMPONENT32F, DEPTH24_STENCIL8, DEPTH32F_STENCIL8 and
3655  *          STENCIL_INDEX8.
3656  *
3657  *      Repeat the test for following width and height:
3658  *          width = 1 and height = 1;
3659  *          width = 256 and height = 512;
3660  *          width = 1280 and height = 720;
3661  *          width = value of MAX_RENDERBUFFER_SIZE and height = 1;
3662  *          width = 1 and height = value of MAX_RENDERBUFFER_SIZE.
3663  */
3664 class StorageTest : public deqp::TestCase
3665 {
3666 public:
3667         /* Public member functions */
3668         StorageTest(deqp::Context& context);
3669
3670         virtual tcu::TestNode::IterateResult iterate();
3671
3672 private:
3673         /* Private static variables. */
3674         static const struct RenderbufferInternalFormatConfiguration
3675         {
3676                 glw::GLenum                internalformat;
3677                 const glw::GLchar* internalformat_name;
3678                 bool                       hasRedComponent;
3679                 bool                       hasGreenComponent;
3680                 bool                       hasBlueComponent;
3681                 bool                       hasAlphaComponent;
3682                 bool                       hasDepthComponent;
3683                 bool                       hasStencilComponent;
3684                 bool                       isColorIntegralFormat;
3685         } s_renderbuffer_internalformat_configuration[];
3686
3687         static const glw::GLuint s_renderbuffer_internalformat_configuration_count;
3688
3689         static const glw::GLfloat s_reference_color[4];
3690         static const glw::GLint   s_reference_color_integer[4];
3691         static const glw::GLfloat s_reference_depth;
3692         static const glw::GLint   s_reference_stencil;
3693
3694         /* Private member functions */
3695         StorageTest(const StorageTest& other);
3696         StorageTest& operator=(const StorageTest& other);
3697
3698         bool PrepareRenderbuffer(StorageTest::RenderbufferInternalFormatConfiguration format, glw::GLuint width,
3699                                                          glw::GLuint height);
3700         void Clear(bool isIntegralFormat);
3701         bool Check(StorageTest::RenderbufferInternalFormatConfiguration format, glw::GLuint width, glw::GLuint height);
3702         void Clean();
3703
3704         /* Private member variables. */
3705         glw::GLuint m_fbo;
3706         glw::GLuint m_rbo;
3707 };
3708 /* StorageTest class */
3709
3710 /** Named Renderbuffer Storage Multisample
3711  *
3712  *      Create two renderbuffer objects. Prepare storage of the first one using
3713  *      NamedRenderbufferStorageMultisample function. Prepare storage of the
3714  *      second one using NamedRenderbufferStorage function.
3715  *
3716  *      Create two framebuffer objects. Attach multisampled renderbuffer to
3717  *      proper attachment points of the first framebuffer. Attach second
3718  *      renderbuffer to proper attachment points of the second framebuffer.
3719  *
3720  *      Clear framebuffer's renderbuffer attachment with reference value. Blit
3721  *      surface of the first framebuffer (multisampled renderbuffer) to the
3722  *      second framebuffer. Fetch the data from the second framebuffer using
3723  *      ReadPixels function. Compare the fetched values with the reference.
3724  *
3725  *      Release all objects.
3726  *
3727  *      Repeat the test for following internal formats:
3728  *
3729  *          R8, R16, RG8, RG16, RGB565, RGBA4, RGB5_A1, RGBA8, RGB10_A2,
3730  *          RGB10_A2UI, RGBA16, SRGB8_ALPHA8, R16F, RG16F, RGBA16F, R32F, RG32F,
3731  *          RGBA32F, R11F_G11F_B10F, R8I, R8UI, R16I, R16UI, R32I, R32UI, RG8I,
3732  *          RG8UI, RG16I, RG16UI, RG32I, RG32UI, RGBA8I, RGBA8UI, RGBA16I,
3733  *          RGBA16UI, RGBA32I, RGBA32UI, DEPTH_COMPONENT16, DEPTH_COMPONENT24,
3734  *          DEPTH_COMPONENT32F, DEPTH24_STENCIL8, DEPTH32F_STENCIL8 and
3735  *          STENCIL_INDEX8.
3736  *
3737  *      Repeat the test for following width and height:
3738  *          width = 1 and height = 1;
3739  *          width = value of MAX_RENDERBUFFER_SIZE and height = 1;
3740  *          width = 1 and height = value of MAX_RENDERBUFFER_SIZE.
3741  *
3742  *      Repeat the test for number of samples in range from 1 to value of
3743  *      MAX_INTEGER_SAMPLES for signed and unsigned integer internal formats or
3744  *      in range from 1 to value of MAX_SAMPLES for all other internal formats.
3745  */
3746 class StorageMultisampleTest : public deqp::TestCase
3747 {
3748 public:
3749         /* Public member functions */
3750         StorageMultisampleTest(deqp::Context& context);
3751
3752         virtual tcu::TestNode::IterateResult iterate();
3753
3754 private:
3755         /* Private static variables. */
3756         static const struct RenderbufferInternalFormatConfiguration
3757         {
3758                 glw::GLenum                internalformat;
3759                 const glw::GLchar* internalformat_name;
3760                 bool                       hasRedComponent;
3761                 bool                       hasGreenComponent;
3762                 bool                       hasBlueComponent;
3763                 bool                       hasAlphaComponent;
3764                 bool                       hasDepthComponent;
3765                 bool                       hasStencilComponent;
3766                 bool                       isColorIntegralFormat;
3767         } s_renderbuffer_internalformat_configuration[];
3768
3769         static const glw::GLuint s_renderbuffer_internalformat_configuration_count;
3770
3771         static const glw::GLfloat s_reference_color[4];
3772         static const glw::GLint   s_reference_color_integer[4];
3773         static const glw::GLfloat s_reference_depth;
3774         static const glw::GLint   s_reference_stencil;
3775
3776         /* Private member functions */
3777         StorageMultisampleTest(const StorageMultisampleTest& other);
3778         StorageMultisampleTest& operator=(const StorageMultisampleTest& other);
3779
3780         bool PrepareRenderbuffer(StorageMultisampleTest::RenderbufferInternalFormatConfiguration format, glw::GLuint width,
3781                                                          glw::GLuint height, glw::GLsizei samples);
3782         void Bind(glw::GLenum target, glw::GLuint selector);
3783         void Blit(glw::GLuint width, glw::GLuint height);
3784         void Clear(bool isIntegralFormat);
3785         bool Check(StorageMultisampleTest::RenderbufferInternalFormatConfiguration format, glw::GLuint width,
3786                            glw::GLuint height);
3787         void Clean();
3788
3789         /* Private member variables. */
3790         glw::GLuint m_fbo[2];
3791         glw::GLuint m_rbo[2];
3792 };
3793 /* StorageMultisampleTest class */
3794
3795 /** Get Named Renderbuffer Parameter
3796  *
3797  *      Create named renderbuffer object with varying width = 1,
3798  *      height = 2, and varying internalformat.
3799  *
3800  *      For following parameter names:
3801  *       -  RENDERBUFFER_WIDTH,
3802  *       -  RENDERBUFFER_HEIGHT,
3803  *       -  RENDERBUFFER_INTERNAL_FORMAT,
3804  *       -  RENDERBUFFER_SAMPLES,
3805  *       -  RENDERBUFFER_RED_SIZE,
3806  *       -  RENDERBUFFER_GREEN_SIZE,
3807  *       -  RENDERBUFFER_BLUE_SIZE,
3808  *       -  RENDERBUFFER_ALPHA_SIZE,
3809  *       -  RENDERBUFFER_DEPTH_SIZE,
3810  *       -  RENDERBUFFER_STENCIL_SIZE
3811  *      query value using GetNamedRenderbufferParameteriv. Expect no error.
3812  *      Compare it with value returned in non-DSA way. Expect equality.
3813  *
3814  *      Repeat test for following internalformats:
3815  *       -  RGBA8,
3816  *       -  DEPTH_COMPONENT24,
3817  *       -  STENCIL_INDEX8,
3818  *       -  DEPTH24_STENCIL8.
3819  *
3820  *      Release objects.
3821  */
3822 class GetParametersTest : public deqp::TestCase
3823 {
3824 public:
3825         /* Public member functions */
3826         GetParametersTest(deqp::Context& context);
3827
3828         virtual tcu::TestNode::IterateResult iterate();
3829
3830 private:
3831         /* Private member functions */
3832         GetParametersTest(const GetParametersTest& other);
3833         GetParametersTest& operator=(const GetParametersTest& other);
3834
3835         /* Private member variables. */
3836         glw::GLuint m_fbo;
3837         glw::GLuint m_rbo;
3838 };
3839 /* GetParametersTest class */
3840
3841 /** Create Renderbuffer Errors
3842  *
3843  *      Check that INVALID_VALUE is generated by CreateRenderbuffers if n is
3844  *      negative.
3845  */
3846 class CreationErrorsTest : public deqp::TestCase
3847 {
3848 public:
3849         /* Public member functions */
3850         CreationErrorsTest(deqp::Context& context);
3851
3852         virtual tcu::TestNode::IterateResult iterate();
3853
3854 private:
3855         /* Private member functions */
3856         CreationErrorsTest(const CreationErrorsTest& other);
3857         CreationErrorsTest& operator=(const CreationErrorsTest& other);
3858 };
3859 /* CreationErrorsTest class */
3860
3861 /** Named Renderbuffer Storage Errors
3862  *
3863  *      Check that INVALID_OPERATION is generated by NamedRenderbufferStorage if
3864  *      renderbuffer is not the name of an existing renderbuffer object.
3865  *
3866  *      Check that INVALID_VALUE is generated by NamedRenderbufferStorage if
3867  *      either of width or height is negative, or greater than the value of
3868  *      MAX_RENDERBUFFER_SIZE.
3869  */
3870 class StorageErrorsTest : public deqp::TestCase
3871 {
3872 public:
3873         /* Public member functions */
3874         StorageErrorsTest(deqp::Context& context);
3875
3876         virtual tcu::TestNode::IterateResult iterate();
3877
3878 private:
3879         /* Private member functions */
3880         StorageErrorsTest(const StorageErrorsTest& other);
3881         StorageErrorsTest& operator=(const StorageErrorsTest& other);
3882
3883         void PrepareObjects();
3884         bool ExpectError(glw::GLenum expected_error, const glw::GLchar* function, const glw::GLchar* conditions);
3885         void Clean();
3886
3887         /* Private member variables. */
3888         glw::GLuint m_rbo_valid;
3889         glw::GLuint m_rbo_invalid;
3890         glw::GLenum m_internalformat_invalid;
3891 };
3892 /* StorageErrorsTest class */
3893
3894 /** Named Renderbuffer Storage Multisample Errors
3895  *
3896  *      Check that INVALID_OPERATION is generated by
3897  *      NamedRenderbufferStorageMultisample function if renderbuffer is not the
3898  *      name of an existing renderbuffer object.
3899  *
3900  *      Check that INVALID_VALUE is generated by
3901  *      NamedRenderbufferStorageMultisample if samples is greater than
3902  *      MAX_SAMPLES.
3903  *
3904  *      Check that INVALID_ENUM is generated by
3905  *      NamedRenderbufferStorageMultisample if internalformat is not a
3906  *      color-renderable, depth-renderable, or stencil-renderable format.
3907  *
3908  *      Check that INVALID_OPERATION is generated by
3909  *      NamedRenderbufferStorageMultisample if internalformat is a signed or
3910  *      unsigned integer format and samples is greater than the value of
3911  *      MAX_INTEGER_SAMPLES.
3912  *
3913  *      Check that INVALID_VALUE is generated by
3914  *      NamedRenderbufferStorageMultisample if either of width or height is
3915  *      negative, or greater than the value of GL_MAX_RENDERBUFFER_SIZE.
3916  */
3917 class StorageMultisampleErrorsTest : public deqp::TestCase
3918 {
3919 public:
3920         /* Public member functions */
3921         StorageMultisampleErrorsTest(deqp::Context& context);
3922
3923         virtual tcu::TestNode::IterateResult iterate();
3924
3925 private:
3926         /* Private member functions */
3927         StorageMultisampleErrorsTest(const StorageMultisampleErrorsTest& other);
3928         StorageMultisampleErrorsTest& operator=(const StorageMultisampleErrorsTest& other);
3929
3930         void PrepareObjects();
3931         bool ExpectError(glw::GLenum expected_error, const glw::GLchar* function, const glw::GLchar* conditions);
3932         void Clean();
3933
3934         /* Private member variables. */
3935         glw::GLuint m_rbo_valid;
3936         glw::GLuint m_rbo_invalid;
3937         glw::GLenum m_internalformat_invalid;
3938         glw::GLint  m_max_samples;
3939         glw::GLint  m_max_integer_samples;
3940 };
3941 /* StorageMultisampleErrorsTest class */
3942
3943 /** Get Named Renderbuffer Parameter Errors
3944  *
3945  *      Check that INVALID_OPERATION is generated by
3946  *      GetNamedRenderbufferParameteriv if renderbuffer is not the name of an
3947  *      existing renderbuffer object.
3948  *
3949  *      Check that INVALID_ENUM is generated by GetNamedRenderbufferParameteriv
3950  *      if parameter name is not one of the accepted parameter names described
3951  *      in specification.
3952  */
3953 class GetParameterErrorsTest : public deqp::TestCase
3954 {
3955 public:
3956         /* Public member functions */
3957         GetParameterErrorsTest(deqp::Context& context);
3958
3959         virtual tcu::TestNode::IterateResult iterate();
3960
3961 private:
3962         /* Private member functions */
3963         GetParameterErrorsTest(const GetParameterErrorsTest& other);
3964         GetParameterErrorsTest& operator=(const GetParameterErrorsTest& other);
3965
3966         void PrepareObjects();
3967         bool ExpectError(glw::GLenum expected_error, const glw::GLchar* function, const glw::GLchar* conditions);
3968         void Clean();
3969
3970         /* Private member variables. */
3971         glw::GLuint m_rbo_valid;
3972         glw::GLuint m_rbo_invalid;
3973         glw::GLenum m_parameter_invalid;
3974 };
3975 /* GetParameterErrorsTest class */
3976 } /* Renderbuffers namespace */
3977
3978 namespace VertexArrays
3979 {
3980 /** Vertex Array Object Creation
3981  *
3982  *     Create at least two vertex array objects using GenVertexArrays function.
3983  *     Check them without binding, using IsVertexArray function. Expect FALSE.
3984  *
3985  *     Create at least two vertex array objects using CreateVertexArrays
3986  *     function. Check them without binding, using IsVertexArray function.
3987  *     Expect TRUE.
3988  *
3989  *     Release objects.
3990  */
3991 class CreationTest : public deqp::TestCase
3992 {
3993 public:
3994         /* Public member functions */
3995         CreationTest(deqp::Context& context);
3996
3997         virtual tcu::TestNode::IterateResult iterate();
3998
3999 private:
4000         /* Private member functions */
4001         CreationTest(const CreationTest& other);
4002         CreationTest& operator=(const CreationTest& other);
4003 };
4004 /* CreationTest class */
4005
4006 /** Vertex Array Object Enable Disable Attributes
4007  *
4008  *      Prepare vertex shader with (MAX_VERTEX_ATTRIBS / 2) attribute variables.
4009  *      Vertex shader shall sum all input attribute variables and pass the sum
4010  *      to transform feedback varying. Build program in two versions:
4011  *          1) with attribute variable names bound to even attribute indexes;
4012  *          2) with attribute variable names bound to odd attribute indexes.
4013  *
4014  *      Prepare and bind vertex array object.
4015  *
4016  *      Prepare buffer object with MAX_VERTEX_ATTRIBS of consecutive numbers.
4017  *      Bound each of the numbers to separate index. Prepare second object for
4018  *      transform feedback result.
4019  *
4020  *      Unbind vertex array object.
4021  *
4022  *      Enable even attribute indexes using EnableVertexArrayAttrib. Expect no
4023  *      error.
4024  *
4025  *      Bind vertex array object.
4026  *
4027  *      Use first program. Draw single point using transform feedback. Expect
4028  *      sum of numbers at even positions in the input (reference) buffer object.
4029  *
4030  *      Unbind vertex array object.
4031  *
4032  *      Disable even attribute indexes using DisableVertexArrayAttrib. Expect no
4033  *      error.
4034  *
4035  *      Enable odd attribute indexes using EnableVertexArrayAttrib. Expect no
4036  *      error.
4037  *
4038  *      Bind vertex array object.
4039  *
4040  *      Use second program. Draw single point using transform feedback. Expect
4041  *      sum of numbers at odd positions in the input (reference) buffer object.
4042  *
4043  *      Unbind vertex array object.
4044  *
4045  *      Release all objects.
4046  */
4047 class EnableDisableAttributesTest : public deqp::TestCase
4048 {
4049 public:
4050         /* Public member functions */
4051         EnableDisableAttributesTest(deqp::Context& context);
4052
4053         virtual tcu::TestNode::IterateResult iterate();
4054
4055 private:
4056         /* Private member functions. */
4057         EnableDisableAttributesTest(const EnableDisableAttributesTest& other);
4058         EnableDisableAttributesTest& operator=(const EnableDisableAttributesTest& other);
4059
4060         glw::GLuint PrepareProgram(const bool bind_even_or_odd);
4061         glw::GLuint BuildProgram(const char* vertex_shader, const bool bind_even_or_odd);
4062         void PrepareVAO();
4063         void PrepareXFB();
4064         bool DrawAndCheck(bool bind_even_or_odd);
4065         bool TurnOnAttributes(bool enable_even, bool enable_odd);
4066         void Clean();
4067
4068         /* Private member variables. */
4069         glw::GLuint m_po_even;
4070         glw::GLuint m_po_odd;
4071         glw::GLuint m_vao;
4072         glw::GLuint m_bo;
4073         glw::GLuint m_bo_xfb;
4074         glw::GLint  m_max_attributes;
4075
4076         /* Private static constants. */
4077         static const glw::GLchar s_vertex_shader_template[];
4078         static const glw::GLchar s_fragment_shader[];
4079 };
4080 /* EnableDisableAttributesTest class */
4081
4082 /** Vertex Array Object Element Buffer
4083  *
4084  *      Prepare GLSL program which passes input attribute to transform feedback
4085  *      varying.
4086  *
4087  *      Create and bind vertex array object.
4088  *
4089  *      Prepare buffer object with integer data {2, 1, 0}. Set this buffer as an
4090  *      input attribute. Use non-DSA functions.
4091  *
4092  *      Unbind vertex array object.
4093  *
4094  *      Prepare buffer object with integer data {2, 1, 0}. Set this buffer as an
4095  *      element buffer using VertexArrayElementBuffer function.
4096  *
4097  *      Bind vertex array object.
4098  *
4099  *      Use the program. Draw three points using transform feedback. Expect
4100  *      result equal to {0, 1, 2}.
4101  *
4102  *      Release all objects.
4103  */
4104 class ElementBufferTest : public deqp::TestCase
4105 {
4106 public:
4107         /* Public member functions */
4108         ElementBufferTest(deqp::Context& context);
4109
4110         virtual tcu::TestNode::IterateResult iterate();
4111
4112 private:
4113         /* Private member functions. */
4114         ElementBufferTest(const ElementBufferTest& other);
4115         ElementBufferTest& operator=(const ElementBufferTest& other);
4116
4117         void PrepareProgram();
4118         bool PrepareVAO();
4119         void PrepareXFB();
4120         bool DrawAndCheck();
4121         void Clean();
4122
4123         /* Private member variables. */
4124         glw::GLuint m_po;
4125         glw::GLuint m_vao;
4126         glw::GLuint m_bo_array;
4127         glw::GLuint m_bo_elements;
4128         glw::GLuint m_bo_xfb;
4129
4130         /* Private static constants. */
4131         static const glw::GLchar s_vertex_shader[];
4132         static const glw::GLchar s_fragment_shader[];
4133 };
4134 /* ElementBufferTest class */
4135
4136 /** Vertex Array Object Vertex Buffer and Buffers
4137  *
4138  *      Prepare GLSL program which passes sum of three input integer attributes
4139  *      to the transform feedback varying.
4140  *
4141  *      Prepare two vertex buffer objects. Setup first buffer with data {0, 1,
4142  *      2, 3}.
4143  *      Setup second buffer with data {4, 5}.
4144  *
4145  *      Create vertex array object. Setup three vertex attributes. Set first
4146  *      buffer object as an input attribute 0 and 1 in interleaved way using
4147  *      VertexArrayVertexBuffer function. Set second buffer object as an input
4148  *      attribute 2 using VertexArrayVertexBuffer function.
4149  *
4150  *      Use program. Draw 2 points using transform feedback. Query results.
4151  *      Expect two values {0+2+4, 1+3+5}.
4152  *
4153  *      Release all data.
4154  *
4155  *      Repeat the test using VertexArrayVertexBuffers function instead of
4156  *      VertexArrayVertexBuffer.
4157  */
4158 class VertexBuffersTest : public deqp::TestCase
4159 {
4160 public:
4161         /* Public member functions */
4162         VertexBuffersTest(deqp::Context& context);
4163
4164         virtual tcu::TestNode::IterateResult iterate();
4165
4166 private:
4167         /* Private member functions. */
4168         VertexBuffersTest(const VertexBuffersTest& other);
4169         VertexBuffersTest& operator=(const VertexBuffersTest& other);
4170
4171         void PrepareProgram();
4172         bool PrepareVAO(bool use_multiple_buffers_function);
4173         void PrepareXFB();
4174         bool DrawAndCheck();
4175         void Clean();
4176
4177         /* Private member variables. */
4178         glw::GLuint m_po;
4179         glw::GLuint m_vao;
4180         glw::GLuint m_bo_array_0;
4181         glw::GLuint m_bo_array_1;
4182         glw::GLuint m_bo_xfb;
4183
4184         /* Private static constants. */
4185         static const glw::GLchar s_vertex_shader[];
4186         static const glw::GLchar s_fragment_shader[];
4187 };
4188 /* VertexBuffersTest class */
4189
4190 /** Vertex Array Object Attribute Format
4191  *
4192  *      Prepare GLSL program which passes sum of two input attributes to the
4193  *      transform feedback varying.
4194  *
4195  *      Create vertex array object.
4196  *
4197  *      Prepare vertex buffer object with reference data of two interleaved
4198  *      arrays. Setup it as input interleaved attributes.
4199  *
4200  *      Setup two consecutive attributes using VertexArrayAttribFormat function.
4201  *
4202  *      Use program. Draw 2 points using transform feedback. Query results.
4203  *      Expect sum of adequate reference values.
4204  *
4205  *      Release all data.
4206  *
4207  *      Repeat the test using VertexArrayAttribIFormat VertexArrayAttribLFormat
4208  *      function instead of VertexArrayAttribFormat.
4209  *
4210  *      Repeat the test using size 1, 2, 3, and 4 (if possible by type).
4211  *
4212  *      Repeat the test using type BYTE, SHORT, INT, FLOAT, DOUBLE,
4213  *      UNSIGNED_BYTE, UNSIGNED_SHORT, UNSIGNED_INT.
4214  *
4215  *      For test with VertexArrayAttribFormat function repeat for normalized and
4216  *      not normalized values.
4217  */
4218 class AttributeFormatTest : public deqp::TestCase
4219 {
4220 public:
4221         /* Public member functions */
4222         AttributeFormatTest(deqp::Context& context);
4223
4224         virtual tcu::TestNode::IterateResult iterate();
4225
4226 private:
4227         /* Private state enumerations. */
4228         enum AtributeFormatFunctionType
4229         {
4230                 ATTRIBUTE_FORMAT_FUNCTION_FLOAT,
4231                 ATTRIBUTE_FORMAT_FUNCTION_DOUBLE,
4232                 ATTRIBUTE_FORMAT_FUNCTION_INTEGER,
4233                 ATTRIBUTE_FORMAT_FUNCTION_COUNT /* Must be last */
4234         };
4235
4236         /* Private member functions. */
4237         AttributeFormatTest(const AttributeFormatTest& other);
4238         AttributeFormatTest& operator=(const AttributeFormatTest& other);
4239
4240         template <typename T>
4241         bool compare(T a, T b);
4242
4243         void PrepareProgram(glw::GLint size, AtributeFormatFunctionType function_selector);
4244
4245         template <typename T>
4246         glw::GLdouble NormalizationScaleFactor();
4247
4248         template <typename T>
4249         bool PrepareVAO(glw::GLint size, glw::GLenum type_gl_name, bool normalized,
4250                                         AtributeFormatFunctionType function_selector);
4251
4252         void PrepareXFB();
4253
4254         template <typename T>
4255         bool DrawAndCheck(glw::GLint size, bool normalized);
4256
4257         void CleanVAO();
4258         void CleanProgram();
4259         void CleanXFB();
4260
4261         /* Private member variables. */
4262         glw::GLuint m_po;
4263         glw::GLuint m_vao;
4264         glw::GLuint m_bo_array;
4265         glw::GLuint m_bo_xfb;
4266
4267         /* Private static constants. */
4268         static const glw::GLchar* s_vertex_shader_head;
4269         static const glw::GLchar* s_vertex_shader_body;
4270         static const glw::GLchar* s_vertex_shader_declaration[ATTRIBUTE_FORMAT_FUNCTION_COUNT][4 /* sizes count */];
4271         static const glw::GLchar* s_fragment_shader;
4272 };
4273 /* AttributeFormatTest class */
4274
4275 /** Vertex Array Attribute Binding
4276  *
4277  *      Prepare GLSL program which passes two integer input attributes to the
4278  *      two-component transform feedback varying vector. Bind first attribute
4279  *      to attribute index 0. Bind second attribute to attribute index 1.
4280  *
4281  *      Create vertex array object.
4282  *
4283  *      Prepare vertex buffer object. Setup the buffer with data {1, 0}.
4284  *      Setup two integer attribute pointers in consecutive way.
4285  *
4286  *      Using VertexArrayAttribBinding function, set up binding index 0 to the
4287  *      attribute index 1. Using VertexArrayAttribBinding function, set up
4288  *      binding index 1 to the attribute index 0.
4289  *
4290  *      Prepare transform feedback buffer object.
4291  *
4292  *      Release all data.
4293  */
4294 class AttributeBindingTest : public deqp::TestCase
4295 {
4296 public:
4297         /* Public member functions */
4298         AttributeBindingTest(deqp::Context& context);
4299
4300         virtual tcu::TestNode::IterateResult iterate();
4301
4302 private:
4303         /* Private member functions. */
4304         AttributeBindingTest(const AttributeBindingTest& other);
4305         AttributeBindingTest& operator=(const AttributeBindingTest& other);
4306
4307         void PrepareProgram();
4308         bool PrepareVAO();
4309         void PrepareXFB();
4310         bool DrawAndCheck();
4311         void Clean();
4312
4313         /* Private member variables. */
4314         glw::GLuint m_po;
4315         glw::GLuint m_vao;
4316         glw::GLuint m_bo_array;
4317         glw::GLuint m_bo_xfb;
4318
4319         /* Private static constants. */
4320         static const glw::GLchar s_vertex_shader[];
4321         static const glw::GLchar s_fragment_shader[];
4322 };
4323 /* AttributeBindingTest class */
4324
4325 class AttributeBindingDivisorTest : public deqp::TestCase
4326 {
4327 public:
4328         /* Public member functions */
4329         AttributeBindingDivisorTest(deqp::Context& context);
4330
4331         virtual tcu::TestNode::IterateResult iterate();
4332
4333 private:
4334         /* Private member functions. */
4335         AttributeBindingDivisorTest(const AttributeBindingDivisorTest& other);
4336         AttributeBindingDivisorTest& operator=(const AttributeBindingDivisorTest& other);
4337
4338         void PrepareProgram();
4339         void PrepareVAO();
4340         void PrepareXFB();
4341         void Draw(glw::GLuint number_of_points, glw::GLuint number_of_instances);
4342         bool SetDivisor(glw::GLuint divisor);
4343         bool CheckXFB(const glw::GLuint count, const glw::GLint expected[], const glw::GLchar* log_message);
4344         void Clean();
4345
4346         /* Private member variables. */
4347         glw::GLuint m_po;
4348         glw::GLuint m_vao;
4349         glw::GLuint m_bo_array;
4350         glw::GLuint m_bo_xfb;
4351
4352         /* Private static constants. */
4353         static const glw::GLchar s_vertex_shader[];
4354         static const glw::GLchar s_fragment_shader[];
4355 };
4356 /* AttributeBindingDivisorTest class */
4357
4358 /* Get Vertex Array
4359  *
4360  *      Create vertex array object.
4361  *
4362  *      Create buffer object. Set this buffer as an element buffer of the vertex
4363  *      array object.
4364  *
4365  *      Query ELEMENT_ARRAY_BUFFER_BINDING using GetVertexArrayiv. Expect buffer
4366  *      ID.
4367  *
4368  *      Release all objects.
4369  */
4370 class GetVertexArrayTest : public deqp::TestCase
4371 {
4372 public:
4373         /* Public member functions */
4374         GetVertexArrayTest(deqp::Context& context);
4375
4376         virtual tcu::TestNode::IterateResult iterate();
4377
4378 private:
4379         /* Private member functions. */
4380         GetVertexArrayTest(const GetVertexArrayTest& other);
4381         GetVertexArrayTest& operator=(const GetVertexArrayTest& other);
4382 };
4383 /* GetVertexArrayTest class */
4384
4385 /** Get Vertex Array Indexed
4386  *
4387  *      Create vertex array object.
4388  *
4389  *      Enable attribute indexes 0, 1, 2 and 3.
4390  *
4391  *      Create 4 buffer objects. Set these buffer as attribute arrays:
4392  *          -  attribute 0 with size 1, type BYTE, normalized, stride 0, offset 0,
4393  *          relative offset 0, binding divisor to 3;
4394  *          -  integer attribute 1 with size 2, type SHORT, stride 2, offset 2,
4395  *          relative offset 0, binding divisor to 2;
4396  *          -  attribute 2 with size 3, type FLOAT, not normalized, stride 0,
4397  *          offset 8, relative offset 4, binding divisor to 1;
4398  *          -  attribute 3 with size 4, type UNSIGNED_INT_2_10_10_10_REV, not
4399  *          normalized, stride 8, offset 4, relative offset 0,
4400  *          binding divisor to 0.
4401  *
4402  *      Query VERTEX_ATTRIB_ARRAY_ENABLED using GetVertexArrayIndexediv. Expect
4403  *      TRUE for consecutive indexes 0-3 and FALSE for index 4.
4404  *
4405  *      Query VERTEX_ATTRIB_ARRAY_SIZE using GetVertexArrayIndexediv. Expect
4406  *      1, 2, 3, 4 for consecutive indexes.
4407  *
4408  *      Query VERTEX_ATTRIB_ARRAY_STRIDE using GetVertexArrayIndexediv. Expect
4409  *      0, 2, 0, 8 for consecutive indexes.
4410  *
4411  *      Query VERTEX_ATTRIB_ARRAY_TYPE using GetVertexArrayIndexediv. Expect
4412  *      BYTE, SHORT, FLOAT, UNSIGNED_INT_2_10_10_10_REV for consecutive indexes.
4413  *
4414  *      Query VERTEX_ATTRIB_ARRAY_NORMALIZED using GetVertexArrayIndexediv.
4415  *      Expect true, false, false, false for consecutive indexes.
4416  *
4417  *      Query VERTEX_ATTRIB_ARRAY_INTEGER using GetVertexArrayIndexediv.
4418  *      Expect true, true, false, true for consecutive indexes.
4419  *
4420  *      Query VERTEX_ATTRIB_ARRAY_LONG using GetVertexArrayIndexediv. Expect
4421  *      false for consecutive indexes.
4422  *
4423  *      Query VERTEX_ATTRIB_ARRAY_DIVISOR using GetVertexArrayIndexediv. Expect
4424  *      3, 2, 1, 0 for consecutive indexes.
4425  *
4426  *      Query VERTEX_ATTRIB_RELATIVE_OFFSET using GetVertexArrayIndexediv.
4427  *      Expect 0, 0, 4, 0 for consecutive indexes.
4428  *
4429  *      Query VERTEX_BINDING_OFFSET using GetVertexArrayIndexed64iv. Expect 0,
4430  *      2, 8, 4 for consecutive indexes.
4431  *
4432  *      Release all objects.
4433  */
4434 class GetVertexArrayIndexedTest : public deqp::TestCase
4435 {
4436 public:
4437         /* Public member functions */
4438         GetVertexArrayIndexedTest(deqp::Context& context);
4439
4440         virtual tcu::TestNode::IterateResult iterate();
4441
4442 private:
4443         /* Private member functions. */
4444         GetVertexArrayIndexedTest(const GetVertexArrayIndexedTest& other);
4445         GetVertexArrayIndexedTest& operator=(const GetVertexArrayIndexedTest& other);
4446
4447         void PrepareVAO();
4448         bool Check(const glw::GLenum pname, const glw::GLuint index, const glw::GLint expected);
4449         bool Check64(const glw::GLenum pname, const glw::GLuint index, const glw::GLint64 expected);
4450
4451         /* Private member variables. */
4452         glw::GLuint m_vao;
4453         glw::GLuint m_bo[4];
4454 };
4455 /* GetVertexArrayIndexedTest class */
4456
4457 /** Vertex Array Defaults
4458  *
4459  *      Create empty vertex array object using CreateVertexArrays function.
4460  *
4461  *      Check that parameter VERTEX_ATTRIB_ARRAY_ENABLED for all possible
4462  *      attributes is equal to value FALSE.
4463  *
4464  *      Check that parameter VERTEX_ATTRIB_ARRAY_SIZE for all possible
4465  *      attributes is equal to value 4.
4466  *
4467  *      Check that parameter VERTEX_ATTRIB_ARRAY_STRIDE for all possible
4468  *      attributes is equal to value 0.
4469  *
4470  *      Check that parameter VERTEX_ATTRIB_ARRAY_TYPE for all possible
4471  *      attributes is equal to value FLOAT.
4472  *
4473  *      Check that parameter VERTEX_ATTRIB_ARRAY_NORMALIZED for all possible
4474  *      attributes is equal to value FALSE.
4475  *
4476  *      Check that parameter VERTEX_ATTRIB_ARRAY_INTEGER for all possible
4477  *      attributes is equal to value FALSE.
4478  *
4479  *      Check that parameter VERTEX_ATTRIB_ARRAY_LONG for all possible
4480  *      attributes is equal to value FALSE.
4481  *
4482  *      Check that parameter VERTEX_ATTRIB_ARRAY_DIVISOR for all possible
4483  *      attributes is equal to value 0.
4484  *
4485  *      Check that parameter VERTEX_ATTRIB_RELATIVE_OFFSET for all possible
4486  *      attributes is equal to value 0.
4487  *
4488  *      Check that parameter VERTEX_BINDING_OFFSET for all possible attributes
4489  *      is equal to value 0.
4490  *
4491  *      Check that parameter ELEMENT_ARRAY_BUFFER_BINDING is equal to value 0.
4492  *
4493  *      Release vertex array object.
4494  */
4495 class DefaultsTest : public deqp::TestCase
4496 {
4497 public:
4498         /* Public member functions */
4499         DefaultsTest(deqp::Context& context);
4500
4501         virtual tcu::TestNode::IterateResult iterate();
4502
4503 private:
4504         /* Private member functions. */
4505         DefaultsTest(const DefaultsTest& other);
4506         DefaultsTest& operator=(const DefaultsTest& other);
4507
4508         void PrepareVAO();
4509         bool Check(const glw::GLenum pname, const glw::GLint expected);
4510         bool CheckIndexed(const glw::GLenum pname, const glw::GLuint index, const glw::GLint expected);
4511         bool CheckIndexed64(const glw::GLenum pname, const glw::GLuint index, const glw::GLint64 expected);
4512
4513         /* Private member variables. */
4514         glw::GLuint m_vao;
4515 };
4516 /* DefaultsTest class */
4517
4518 /** Vertex Array Object Creation Error
4519  *
4520  *      Check that INVALID_VALUE is generated if n is negative.
4521  */
4522 class CreationErrorTest : public deqp::TestCase
4523 {
4524 public:
4525         /* Public member functions */
4526         CreationErrorTest(deqp::Context& context);
4527
4528         virtual tcu::TestNode::IterateResult iterate();
4529
4530 private:
4531         /* Private member functions. */
4532         CreationErrorTest(const CreationErrorTest& other);
4533         CreationErrorTest& operator=(const CreationErrorTest& other);
4534
4535         bool CheckError(const glw::GLenum expected, const glw::GLchar* log_message);
4536 };
4537 /* CreationErrorTest class */
4538
4539 /** Vertex Array Object Enable Disable Attribute Errors
4540  *
4541  *      Check that INVALID_OPERATION is generated by EnableVertexArrayAttrib and
4542  *      DisableVertexArrayAttrib if vaobj is not the name of an existing vertex
4543  *      array object.
4544  *
4545  *      Check that INVALID_VALUE is generated if index is greater than or equal
4546  *      to MAX_VERTEX_ATTRIBS.
4547  */
4548 class EnableDisableAttributeErrorsTest : public deqp::TestCase
4549 {
4550 public:
4551         /* Public member functions */
4552         EnableDisableAttributeErrorsTest(deqp::Context& context);
4553
4554         virtual tcu::TestNode::IterateResult iterate();
4555
4556 private:
4557         /* Private member functions. */
4558         EnableDisableAttributeErrorsTest(const EnableDisableAttributeErrorsTest& other);
4559         EnableDisableAttributeErrorsTest& operator=(const EnableDisableAttributeErrorsTest& other);
4560
4561         bool CheckError(const glw::GLenum expected, const glw::GLchar* log_message);
4562 };
4563 /* EnableDisableAttributeErrorsTest class */
4564
4565 /** Vertex Array Object Element Buffer Errors
4566  *
4567  *      Check that INVALID_OPERATION error is generated by VertexArrayElementBuffer if vaobj is not the name
4568  *      of an existing vertex array object.
4569  *
4570  *      Check that INVALID_OPERATION error is generated by VertexArrayElementBuffer if buffer is not zero or
4571  *      the name of an existing buffer object.
4572  */
4573 class ElementBufferErrorsTest : public deqp::TestCase
4574 {
4575 public:
4576         /* Public member functions */
4577         ElementBufferErrorsTest(deqp::Context& context);
4578
4579         virtual tcu::TestNode::IterateResult iterate();
4580
4581 private:
4582         /* Private member functions. */
4583         ElementBufferErrorsTest(const ElementBufferErrorsTest& other);
4584         ElementBufferErrorsTest& operator=(const ElementBufferErrorsTest& other);
4585
4586         bool CheckError(const glw::GLenum expected, const glw::GLchar* log_message);
4587 };
4588 /* ElementBuffersErrorsTest class */
4589
4590 /** Vertex Array Object Buffer and Buffers Errors
4591  *
4592  *      Check that INVALID_OPERATION is generated by VertexArrayVertexBuffer and
4593  *      VertexArrayVertexBuffers if vaobj is not the name of an existing vertex
4594  *      array object.
4595  *
4596  *      Check that INVALID_VALUE is generated by VertexArrayVertexBuffer if
4597  *      buffer is not zero or the name of an existing buffer object (as returned
4598  *      by GenBuffers or CreateBuffers).
4599  *
4600  *      Check that INVALID_OPERATION is generated by VertexArrayVertexBuffers if
4601  *      any value in buffers is not zero or the name of an existing buffer
4602  *      object.
4603  *
4604  *      Check that INVALID_VALUE is generated by VertexArrayVertexBuffer if
4605  *      bindingindex is greater than or equal to the value of
4606  *      MAX_VERTEX_ATTRIB_BINDINGS.
4607  *
4608  *      Check that INVALID_OPERATION is generated by VertexArrayVertexBuffers if
4609  *      first+count is greater than the value of MAX_VERTEX_ATTRIB_BINDINGS.
4610  *
4611  *      Check that INVALID_VALUE is generated by VertexArrayVertexBuffer if
4612  *      offset or stride is less than zero, or if stride is greater than the
4613  *      value of MAX_VERTEX_ATTRIB_STRIDE.
4614  *
4615  *      Check that INVALID_VALUE is generated by VertexArrayVertexBuffers if any
4616  *      value in offsets or strides is negative, or if a value is stride is
4617  *      greater than the value of MAX_VERTEX_ATTRIB_STRIDE.
4618  */
4619 class VertexBuffersErrorsTest : public deqp::TestCase
4620 {
4621 public:
4622         /* Public member functions */
4623         VertexBuffersErrorsTest(deqp::Context& context);
4624
4625         virtual tcu::TestNode::IterateResult iterate();
4626
4627 private:
4628         /* Private member functions. */
4629         VertexBuffersErrorsTest(const VertexBuffersErrorsTest& other);
4630         VertexBuffersErrorsTest& operator=(const VertexBuffersErrorsTest& other);
4631
4632         bool CheckError(const glw::GLenum expected, const glw::GLchar* log_message);
4633 };
4634 /* VertexBuffersErrorsTest class */
4635
4636 /** Vertex Array Object Attribute Format Errors
4637  *
4638  *      Check that INVALID_VALUE is generated by VertexArrayAttrib*Format if
4639  *      attribindex is greater than or equal to the value of MAX_VERTEX_ATTRIBS.
4640  *
4641  *      Check that INVALID_VALUE is generated by VertexArrayAttrib*Format if
4642  *      size is not one of the accepted values.
4643  *
4644  *      Check that INVALID_VALUE is generated by VertexArrayAttrib*Format if
4645  *      relativeoffset is greater than the value of
4646  *      MAX_VERTEX_ATTRIB_RELATIVE_OFFSET.
4647  *
4648  *      Check that INVALID_ENUM is generated by VertexArrayAttrib*Format if type
4649  *      is not one of the accepted tokens.
4650  *
4651  *      Check that INVALID_ENUM is generated by VertexArrayAttrib{IL}Format if
4652  *      type is UNSIGNED_INT_10F_11F_11F_REV.
4653  *
4654  *      Check that INVALID_OPERATION is generated by VertexArrayAttrib*Format if
4655  *      vaobj is not the name of an existing vertex array object.
4656  *
4657  *      Check that INVALID_OPERATION is generated by VertexArrayAttribFormat
4658  *      under any of the following conditions:
4659  *       -  size is BGRA and type is not UNSIGNED_BYTE, INT_2_10_10_10_REV or
4660  *          UNSIGNED_INT_2_10_10_10_REV,
4661  *       -  type is INT_2_10_10_10_REV or UNSIGNED_INT_2_10_10_10_REV, and size
4662  *          is neither 4 nor BGRA,
4663  *       -  type is UNSIGNED_INT_10F_11F_11F_REV and size is not 3,
4664  *       -  size is BGRA and normalized is FALSE.
4665  */
4666 class AttributeFormatErrorsTest : public deqp::TestCase
4667 {
4668 public:
4669         /* Public member functions */
4670         AttributeFormatErrorsTest(deqp::Context& context);
4671
4672         virtual tcu::TestNode::IterateResult iterate();
4673
4674 private:
4675         /* Private member functions. */
4676         AttributeFormatErrorsTest(const AttributeFormatErrorsTest& other);
4677         AttributeFormatErrorsTest& operator=(const AttributeFormatErrorsTest& other);
4678
4679         bool CheckError(const glw::GLenum expected, const glw::GLchar* log_message);
4680 };
4681 /* AttributeFormatErrorsTest class */
4682
4683 /** Vertex Array Attribute Binding Errors
4684  *
4685  *      Check that INVALID_OPERATION is generated by VertexArrayAttribBinding if
4686  *      vaobj is not the name of an existing vertex array object.
4687  *
4688  *      Check that INVALID_VALUE is generated by VertexArrayAttribBinding if
4689  *      attribindex is greater than or equal to the value of MAX_VERTEX_ATTRIBS.
4690  *
4691  *      Check that INVALID_VALUE is generated by VertexArrayAttribBinding if
4692  *      bindingindex is greater than or equal to the value of
4693  *      MAX_VERTEX_ATTRIB_BINDINGS.
4694  */
4695 class AttributeBindingErrorsTest : public deqp::TestCase
4696 {
4697 public:
4698         /* Public member functions */
4699         AttributeBindingErrorsTest(deqp::Context& context);
4700
4701         virtual tcu::TestNode::IterateResult iterate();
4702
4703 private:
4704         /* Private member functions. */
4705         AttributeBindingErrorsTest(const AttributeBindingErrorsTest& other);
4706         AttributeBindingErrorsTest& operator=(const AttributeBindingErrorsTest& other);
4707
4708         bool CheckError(const glw::GLenum expected, const glw::GLchar* log_message);
4709 };
4710 /* AttributeBindingErrorsTest class */
4711
4712 /** Vertex Array Binding Divisor Errors
4713  *
4714  *      Check that INVALID_VALUE is generated by VertexArrayBindingDivisor if
4715  *      bindingindex is greater than or equal to the value of
4716  *      MAX_VERTEX_ATTRIB_BINDINGS.
4717  *
4718  *      Check that INVALID_OPERATION is generated by VertexArrayBindingDivisor
4719  *      if vaobj is not the name of an existing vertex array object.
4720  */
4721 class AttributeBindingDivisorErrorsTest : public deqp::TestCase
4722 {
4723 public:
4724         /* Public member functions */
4725         AttributeBindingDivisorErrorsTest(deqp::Context& context);
4726
4727         virtual tcu::TestNode::IterateResult iterate();
4728
4729 private:
4730         /* Private member functions. */
4731         AttributeBindingDivisorErrorsTest(const AttributeBindingDivisorErrorsTest& other);
4732         AttributeBindingDivisorErrorsTest& operator=(const AttributeBindingDivisorErrorsTest& other);
4733
4734         bool CheckError(const glw::GLenum expected, const glw::GLchar* log_message);
4735 };
4736 /* AttributeBindingDivisorErrorsTest class */
4737
4738 /** Get Vertex Array Errors
4739  *
4740  *      Check that INVALID_OPERATION error is generated by GetVertexArrayiv if
4741  *      vaobj is not the name of an existing vertex array object.
4742  *
4743  *      Check that INVALID_ENUM error is generated by GetVertexArrayiv if pname
4744  *      is not ELEMENT_ARRAY_BUFFER_BINDING.
4745  */
4746 class GetVertexArrayErrorsTest : public deqp::TestCase
4747 {
4748 public:
4749         /* Public member functions */
4750         GetVertexArrayErrorsTest(deqp::Context& context);
4751
4752         virtual tcu::TestNode::IterateResult iterate();
4753
4754 private:
4755         /* Private member functions. */
4756         GetVertexArrayErrorsTest(const GetVertexArrayErrorsTest& other);
4757         GetVertexArrayErrorsTest& operator=(const GetVertexArrayErrorsTest& other);
4758
4759         bool CheckError(const glw::GLenum expected, const glw::GLchar* log_message);
4760 };
4761 /* GetVertexArrayErrorsTest class */
4762
4763 /** Get Vertex Array Indexed Errors
4764  *
4765  *      Check that INVALID_OPERATION error is generated by
4766  *      GetVertexArrayIndexediv and GetVertexArrayIndexed64iv if vaobj is not
4767  *      the name of an existing vertex array object.
4768  *
4769  *      Check that INVALID_VALUE error is generated by GetVertexArrayIndexediv
4770  *      and GetVertexArrayIndexed64iv if index is greater than or equal to the
4771  *      value of MAX_VERTEX_ATTRIBS.
4772  *
4773  *      Check that INVALID_ENUM error is generated by GetVertexArrayIndexediv if
4774  *      pname is not one of the valid values:
4775  *       -  VERTEX_ATTRIB_ARRAY_ENABLED,
4776  *       -  VERTEX_ATTRIB_ARRAY_SIZE,
4777  *       -  VERTEX_ATTRIB_ARRAY_STRIDE,
4778  *       -  VERTEX_ATTRIB_ARRAY_TYPE,
4779  *       -  VERTEX_ATTRIB_ARRAY_NORMALIZED,
4780  *       -  VERTEX_ATTRIB_ARRAY_INTEGER,
4781  *       -  VERTEX_ATTRIB_ARRAY_LONG,
4782  *       -  VERTEX_ATTRIB_ARRAY_DIVISOR,
4783  *       -  VERTEX_ATTRIB_RELATIVE_OFFSET.
4784  *
4785  *      Check that INVALID_ENUM error is generated by GetVertexArrayIndexed64iv
4786  *      if pname is not VERTEX_BINDING_OFFSET.
4787  */
4788 class GetVertexArrayIndexedErrorsTest : public deqp::TestCase
4789 {
4790 public:
4791         /* Public member functions */
4792         GetVertexArrayIndexedErrorsTest(deqp::Context& context);
4793
4794         virtual tcu::TestNode::IterateResult iterate();
4795
4796 private:
4797         /* Private member functions. */
4798         GetVertexArrayIndexedErrorsTest(const GetVertexArrayIndexedErrorsTest& other);
4799         GetVertexArrayIndexedErrorsTest& operator=(const GetVertexArrayIndexedErrorsTest& other);
4800
4801         bool CheckError(const glw::GLenum expected, const glw::GLchar* log_message);
4802 };
4803 /* GetVertexArrayIndexedErrorsTest class */
4804
4805 namespace Utilities
4806 {
4807 std::string itoa(glw::GLuint i);
4808 std::string replace(const std::string& src, const std::string& key, const std::string& value);
4809 } /* Vertex Arrays utilities class */
4810 } /* VertexArrays namespace */
4811
4812 /* Direct State Access Textures Tests */
4813 namespace Textures
4814 {
4815 /** @class CreationTest
4816  *
4817  *  @brief Direct State Access Texture Creation test cases.
4818  *
4819  *  Test follows the steps:
4820  *
4821  *      Create at least two texture objects using GenTextures function. Check
4822  *      them without binding, using IsTexture function. Expect FALSE.
4823  *
4824  *      Create at least two texture objects using CreateTextures function. Check
4825  *      them without binding, using IsTexture function. Expect TRUE. Repeat this
4826  *      step for all targets:
4827  *          -  TEXTURE_1D,
4828  *          -  TEXTURE_2D,
4829  *          -  TEXTURE_3D,
4830  *          -  TEXTURE_1D_ARRAY,
4831  *          -  TEXTURE_2D_ARRAY,
4832  *          -  TEXTURE_RECTANGLE,
4833  *          -  TEXTURE_CUBE_MAP,
4834  *          -  TEXTURE_CUBE_MAP_ARRAY,
4835  *          -  TEXTURE_BUFFER,
4836  *          -  TEXTURE_2D_MULTISAMPLE and
4837  *          -  TEXTURE_2D_MULTISAMPLE_ARRAY.
4838  *
4839  *      Release objects.
4840  */
4841 class CreationTest : public deqp::TestCase
4842 {
4843 public:
4844         /* Public member functions */
4845         CreationTest(deqp::Context& context);
4846
4847         virtual tcu::TestNode::IterateResult iterate();
4848
4849 private:
4850         /* Private member functions */
4851         CreationTest(const CreationTest& other);
4852         CreationTest& operator=(const CreationTest& other);
4853 };
4854 /* CreationTest class */
4855
4856 class Reference
4857 {
4858 public:
4859         template <typename T, glw::GLint S, bool N>
4860         static glw::GLenum InternalFormat();
4861
4862         template <glw::GLint S, bool N>
4863         static glw::GLenum Format();
4864
4865         template <typename T>
4866         static glw::GLenum Type();
4867
4868         template <typename T, bool N>
4869         static const T* ReferenceData();
4870
4871         static glw::GLuint ReferenceDataCount();
4872
4873         template <typename T>
4874         static glw::GLuint ReferenceDataSize();
4875
4876         template <typename T>
4877         static bool Compare(const T a, const T b);
4878
4879 private:
4880         static const glw::GLuint s_reference_count = 2 /* 1D */ * 3 /* 2D */ * 4 /* 3D */ * 4 /* components */;
4881 };
4882
4883 /** @class BufferTest
4884  *
4885  *  @brief Direct State Access of texture buffers.
4886  *
4887  *  @tparam T      Type.
4888  *  @tparam S      Size.
4889  *  @tparam N      Is normalized.
4890  *
4891  *  Test follows the steps:
4892  *
4893  *      Make test for following DSA functions:
4894  *        -  TextureBuffer,
4895  *        -  TextureBufferRange
4896  *       and following texture internal formats:
4897  *        -  R8,
4898  *        -  R16,
4899  *        -  R16F,
4900  *        -  R32F,
4901  *        -  R8I,
4902  *        -  R16I,
4903  *        -  R32I,
4904  *        -  R8UI,
4905  *        -  R16UI,
4906  *        -  R32UI,
4907  *        -  RG8,
4908  *        -  RG16,
4909  *        -  RG16F,
4910  *        -  RG32F,
4911  *        -  RG8I,
4912  *        -  RG16I,
4913  *        -  RG32I,
4914  *        -  RG8UI,
4915  *        -  RG16UI,
4916  *        -  RG32UI,
4917  *        -  RGB32F,
4918  *        -  RGB32I,
4919  *        -  RGB32UI,
4920  *        -  RGBA8,
4921  *        -  RGBA16,
4922  *        -  RGBA16F,
4923  *        -  RGBA32F,
4924  *        -  RGBA8I,
4925  *        -  RGBA16I,
4926  *        -  RGBA32I,
4927  *        -  RGBA8UI,
4928  *        -  RGBA16UI,
4929  *        -  RGBA32UI.
4930  *
4931  *          Prepare program which draws textured quad 6 x 1 pixels in size. The
4932  *          sampled texture shall be buffer texture which linearly store two rows
4933  *          of three pixels.
4934  *
4935  *          Prepare framebuffer 6 x 1 pixels in size.
4936  *
4937  *          Prepare texture object with attached buffer object as a storage using
4938  *          TextureBuffer or TextureBufferRange function. When TextureBufferRange is
4939  *          being used, test non-zero offset setup. The buffer object shall contain
4940  *          unique reference values. Texture filtering shall be set to NEAREST.
4941  *
4942  *          Using prepared GL objects draw a quad. Fetch framebuffer data using
4943  *          ReadPixels function. Compare the results with the reference data. Expect
4944  *          equality.
4945  *
4946  *          Release all objects.
4947  */
4948 template <typename T, glw::GLint S, bool N>
4949 class BufferTest : public deqp::TestCase, Reference
4950 {
4951 public:
4952         /* Public member functions. */
4953         BufferTest(deqp::Context& context, const char* name);
4954
4955         virtual tcu::TestNode::IterateResult iterate();
4956
4957 private:
4958         /* Private constructors. */
4959         BufferTest(const BufferTest& other);
4960         BufferTest& operator=(const BufferTest& other);
4961
4962         /* Private member functions. */
4963         static glw::GLuint   TestReferenceDataCount();
4964
4965         static glw::GLuint TestReferenceDataSize();
4966
4967         static const glw::GLchar* FragmentShaderDeclaration();
4968
4969         bool CreateBufferTexture(bool use_range_version);
4970
4971         bool Check();
4972
4973         bool Test(bool use_range_version);
4974
4975         bool PrepareFramebuffer(const glw::GLenum internal_format);
4976         void PrepareProgram(const glw::GLchar* variable_declaration);
4977         void PrepareVertexArray();
4978         void Draw();
4979         void CleanBufferTexture();
4980         void CleanFramebuffer();
4981         void CleanProgram();
4982         void CleanErrors();
4983         void CleanVertexArray();
4984
4985         /* Private member variables. */
4986         glw::GLuint m_fbo;
4987         glw::GLuint m_rbo;
4988         glw::GLuint m_po;
4989         glw::GLuint m_to;
4990         glw::GLuint m_bo;
4991         glw::GLuint m_vao;
4992
4993         /* Private static constants. */
4994         static const glw::GLuint  s_fbo_size_x = 6;
4995         static const glw::GLuint  s_fbo_size_y = 1;
4996         static const glw::GLchar* s_vertex_shader;
4997         static const glw::GLchar* s_fragment_shader_head;
4998         static const glw::GLchar* s_fragment_shader_fdecl_lowp;
4999         static const glw::GLchar* s_fragment_shader_idecl_lowp;
5000         static const glw::GLchar* s_fragment_shader_udecl_lowp;
5001         static const glw::GLchar* s_fragment_shader_fdecl_mediump;
5002         static const glw::GLchar* s_fragment_shader_idecl_mediump;
5003         static const glw::GLchar* s_fragment_shader_udecl_mediump;
5004         static const glw::GLchar* s_fragment_shader_fdecl_highp;
5005         static const glw::GLchar* s_fragment_shader_idecl_highp;
5006         static const glw::GLchar* s_fragment_shader_udecl_highp;
5007         static const glw::GLchar* s_fragment_shader_tail;
5008 };
5009
5010 /** @brief Fragment shader part selector.
5011  *
5012  *  @return Array of characters with source code.
5013  */
5014 template <typename T, glw::GLint S, bool N>
5015 const glw::GLchar* BufferTest<T, S, N>::FragmentShaderDeclaration()
5016 {
5017         if (typeid(T) == typeid(glw::GLbyte))
5018         {
5019                 return s_fragment_shader_idecl_lowp;
5020         }
5021
5022         if (typeid(T) == typeid(glw::GLubyte))
5023         {
5024                 return N ? s_fragment_shader_fdecl_lowp : s_fragment_shader_udecl_lowp;
5025         }
5026
5027         if (typeid(T) == typeid(glw::GLshort))
5028         {
5029                 return s_fragment_shader_idecl_mediump;
5030         }
5031
5032         if (typeid(T) == typeid(glw::GLushort))
5033         {
5034                 return N ? s_fragment_shader_fdecl_mediump : s_fragment_shader_udecl_mediump;
5035         }
5036
5037         if (typeid(T) == typeid(glw::GLint))
5038         {
5039                 return s_fragment_shader_idecl_highp;
5040         }
5041
5042         if (typeid(T) == typeid(glw::GLuint))
5043         {
5044                 return s_fragment_shader_udecl_highp;
5045         }
5046
5047         return s_fragment_shader_fdecl_highp;
5048 }
5049
5050 /* BufferTest class */
5051
5052 /** @class StorageAndSubImageTest
5053  *
5054  *      Make test for following DSA storage functions:
5055  *       -  TextureStorage1D,
5056  *       -  TextureStorage2D,
5057  *       -  TextureStorage3D
5058  *      and DSA SubImage functions:
5059  *       -  TextureSubImage1D,
5060  *       -  TextureSubImage2D,
5061  *       -  TextureSubImage3D.
5062  *
5063  *      Test following internal formats:
5064  *       -  R8,
5065  *       -  R16,
5066  *       -  R16F,
5067  *       -  R32F,
5068  *       -  R8I,
5069  *       -  R16I,
5070  *       -  R32I,
5071  *       -  R8UI,
5072  *       -  R16UI,
5073  *       -  R32UI,
5074  *       -  RG8,
5075  *       -  RG16,
5076  *       -  RG16F,
5077  *       -  RG32F,
5078  *       -  RG8I,
5079  *       -  RG16I,
5080  *       -  RG32I,
5081  *       -  RG8UI,
5082  *       -  RG16UI,
5083  *       -  RG32UI,
5084  *       -  RGB32F,
5085  *       -  RGB32I,
5086  *       -  RGB32UI,
5087  *       -  RGBA8,
5088  *       -  RGBA16,
5089  *       -  RGBA16F,
5090  *       -  RGBA32F,
5091  *       -  RGBA8I,
5092  *       -  RGBA16I,
5093  *       -  RGBA32I,
5094  *       -  RGBA8UI,
5095  *       -  RGBA16UI,
5096  *       -  RGBA32UI.
5097  *
5098  *      Create texture and prepare its storage with the tested function and
5099  *      reference data. The texture dimensions shall be 2x3x4 texels in
5100  *      corresponding directions (if available).
5101  *
5102  *      Prepare GLSL program with fragment shader which fetches texture and passes
5103  *      it to the framebuffer in serialized way.
5104  *
5105  *      Prepare framebuffer 24 x 1 pixels in size.
5106  *
5107  *      Make draw call with prepared texture and program. Fetch framebuffer and
5108  *      compare values with the reference data. Expect equality.
5109  *
5110  *      Release all objects.
5111  */
5112 class StorageAndSubImageTest : public deqp::TestCase, Reference
5113 {
5114 public:
5115         /* Public member functions. */
5116         StorageAndSubImageTest(deqp::Context& context);
5117
5118         virtual tcu::TestNode::IterateResult iterate();
5119
5120 private:
5121         /* Private constructors. */
5122         StorageAndSubImageTest(const StorageAndSubImageTest& other);
5123         StorageAndSubImageTest& operator=(const StorageAndSubImageTest& other);
5124
5125         /* Private member functions. */
5126         template <glw::GLint S, glw::GLuint D>
5127         static glw::GLuint TestReferenceDataCount();
5128
5129         template <glw::GLuint D>
5130         static glw::GLuint      TestReferenceDataWidth();
5131
5132         template <glw::GLuint D>
5133         static glw::GLuint      TestReferenceDataHeight();
5134
5135         template <glw::GLuint D>
5136         static glw::GLuint      TestReferenceDataDepth();
5137
5138         template <typename T, glw::GLint S, glw::GLuint D>
5139         static glw::GLuint TestReferenceDataSize();
5140
5141         template <typename T, bool N, glw::GLuint D>
5142         static const glw::GLchar* FragmentShaderDeclaration();
5143
5144         template <glw::GLuint    D>
5145         static const glw::GLchar* FragmentShaderTail();
5146
5147         template <glw::GLuint D>
5148         static glw::GLenum      TextureTarget();
5149
5150         template <glw::GLuint D, bool I>
5151         bool TextureSubImage(glw::GLenum target, glw::GLuint texture, glw::GLint level, glw::GLint internalformat,
5152                                                  glw::GLsizei width, glw::GLsizei height, glw::GLsizei depth, glw::GLenum format,
5153                                                  glw::GLenum type, const glw::GLvoid* data);
5154
5155         template <glw::GLuint D, bool I>
5156         bool TextureStorage(glw::GLenum target, glw::GLuint texture, glw::GLsizei levels, glw::GLenum internalformat,
5157                                                 glw::GLsizei width, glw::GLsizei height, glw::GLsizei depth);
5158
5159         template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
5160         bool CreateTexture();
5161
5162         template <typename T, glw::GLint S, bool N, glw::GLuint D>
5163         bool Check();
5164
5165         template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
5166         bool Test();
5167
5168         template <typename T, bool N, glw::GLuint D, bool I>
5169         bool LoopTestOverS(bool skip_rgb);
5170
5171         template <typename T, bool N, bool I>
5172         bool LoopTestOverDOverS(bool skip_rgb);
5173
5174         void PrepareFramebuffer(const glw::GLenum internal_format, const glw::GLuint D);
5175         void PrepareProgram(const glw::GLchar* variable_declaration, const glw::GLchar* tail);
5176         void PrepareVertexArray();
5177         void Draw();
5178         void CleanTexture();
5179         void CleanFramebuffer();
5180         void CleanProgram();
5181         void CleanErrors();
5182         void CleanVertexArray();
5183
5184         /* Private member variables. */
5185         glw::GLuint m_fbo;
5186         glw::GLuint m_rbo;
5187         glw::GLuint m_po;
5188         glw::GLuint m_to;
5189         glw::GLuint m_vao;
5190
5191         /* Private static constants. */
5192         static const glw::GLchar* s_vertex_shader;
5193         static const glw::GLchar* s_fragment_shader_head;
5194         static const glw::GLchar* s_fragment_shader_1D_fdecl_lowp;
5195         static const glw::GLchar* s_fragment_shader_1D_idecl_lowp;
5196         static const glw::GLchar* s_fragment_shader_1D_udecl_lowp;
5197         static const glw::GLchar* s_fragment_shader_1D_fdecl_mediump;
5198         static const glw::GLchar* s_fragment_shader_1D_idecl_mediump;
5199         static const glw::GLchar* s_fragment_shader_1D_udecl_mediump;
5200         static const glw::GLchar* s_fragment_shader_1D_fdecl_highp;
5201         static const glw::GLchar* s_fragment_shader_1D_idecl_highp;
5202         static const glw::GLchar* s_fragment_shader_1D_udecl_highp;
5203         static const glw::GLchar* s_fragment_shader_2D_fdecl_lowp;
5204         static const glw::GLchar* s_fragment_shader_2D_idecl_lowp;
5205         static const glw::GLchar* s_fragment_shader_2D_udecl_lowp;
5206         static const glw::GLchar* s_fragment_shader_2D_fdecl_mediump;
5207         static const glw::GLchar* s_fragment_shader_2D_idecl_mediump;
5208         static const glw::GLchar* s_fragment_shader_2D_udecl_mediump;
5209         static const glw::GLchar* s_fragment_shader_2D_fdecl_highp;
5210         static const glw::GLchar* s_fragment_shader_2D_idecl_highp;
5211         static const glw::GLchar* s_fragment_shader_2D_udecl_highp;
5212         static const glw::GLchar* s_fragment_shader_3D_fdecl_lowp;
5213         static const glw::GLchar* s_fragment_shader_3D_idecl_lowp;
5214         static const glw::GLchar* s_fragment_shader_3D_udecl_lowp;
5215         static const glw::GLchar* s_fragment_shader_3D_fdecl_mediump;
5216         static const glw::GLchar* s_fragment_shader_3D_idecl_mediump;
5217         static const glw::GLchar* s_fragment_shader_3D_udecl_mediump;
5218         static const glw::GLchar* s_fragment_shader_3D_fdecl_highp;
5219         static const glw::GLchar* s_fragment_shader_3D_idecl_highp;
5220         static const glw::GLchar* s_fragment_shader_3D_udecl_highp;
5221         static const glw::GLchar* s_fragment_shader_1D_tail;
5222         static const glw::GLchar* s_fragment_shader_2D_tail;
5223         static const glw::GLchar* s_fragment_shader_3D_tail;
5224 };
5225 /* StorageAndSubImageTest class */
5226
5227 /** class StorageMultisampleTest
5228  *
5229  *      Make test for following DSA functions:
5230  *       -  TextureStorage2DMultisample and
5231  *       -  TextureStorage3DMultisample.
5232  *
5233  *      Test following internal formats:
5234  *       -  R8,
5235  *       -  R16,
5236  *       -  R16F,
5237  *       -  R32F,
5238  *       -  R8I,
5239  *       -  R16I,
5240  *       -  R32I,
5241  *       -  R8UI,
5242  *       -  R16UI,
5243  *       -  R32UI,
5244  *       -  RG8,
5245  *       -  RG16,
5246  *       -  RG16F,
5247  *       -  RG32F,
5248  *       -  RG8I,
5249  *       -  RG16I,
5250  *       -  RG32I,
5251  *       -  RG8UI,
5252  *       -  RG16UI,
5253  *       -  RG32UI,
5254  *       -  RGB32F,
5255  *       -  RGB32I,
5256  *       -  RGB32UI,
5257  *       -  RGBA8,
5258  *       -  RGBA16,
5259  *       -  RGBA16F,
5260  *       -  RGBA32F,
5261  *       -  RGBA8I,
5262  *       -  RGBA16I,
5263  *       -  RGBA32I,
5264  *       -  RGBA8UI,
5265  *       -  RGBA16UI,
5266  *       -  RGBA32UI.
5267  *
5268  *      Create multisample texture and prepare its storage with the tested
5269  *      function. The texture dimensions shall be 2x3x4 texels in corresponding
5270  *      directions (if available) and two samples per texel.
5271  *
5272  *      Prepare two framebuffers. The first one with the multisample texture
5273  *      as a color attachment with size 2x3 pixels and 4 color attachments
5274  *      (layers). The second one with non-multisample renderbuffer storage
5275  *      similar in size.
5276  *
5277  *      Prepare GLSL program which draws explicitly reference data to
5278  *      multisample texture framebuffer.
5279  *
5280  *      Use program to draw the reference data into multisample texture.
5281  *
5282  *      Prepare second GLSL program with fragment shader which passes samples of
5283  *      the input texture to the separate framebuffer pixels.
5284  *
5285  *      Use the second program to draw the multisample texture into
5286  *      renderbuffer.
5287  *
5288  *      Fetch framebuffer data and compare with the reference values. Expect
5289  *      equality.
5290  *
5291  *      Release all objects.
5292  */
5293 class StorageMultisampleTest : public deqp::TestCase, Reference
5294 {
5295 public:
5296         /* Public member functions. */
5297         StorageMultisampleTest(deqp::Context& context);
5298
5299         virtual tcu::TestNode::IterateResult iterate();
5300
5301 private:
5302         /* Private constructors. */
5303         StorageMultisampleTest(const StorageMultisampleTest& other);
5304         StorageMultisampleTest& operator=(const StorageMultisampleTest& other);
5305
5306         /* Private member functions. */
5307         template <glw::GLint S, glw::GLuint D>
5308         static glw::GLuint TestReferenceDataCount();
5309
5310         template <glw::GLuint D>
5311         static glw::GLuint      TestReferenceDataWidth();
5312
5313         template <glw::GLuint D>
5314         static glw::GLuint      TestReferenceDataHeight();
5315
5316         template <glw::GLuint D>
5317         static glw::GLuint      TestReferenceDataDepth();
5318
5319         template <typename T, glw::GLint S, glw::GLuint D>
5320         static glw::GLuint TestReferenceDataSize();
5321
5322         template <typename T, bool N, glw::GLuint D>
5323         static const glw::GLchar* FragmentShaderDeclarationMultisample();
5324
5325         template <typename T, bool N, glw::GLuint D>
5326         static const glw::GLchar* FragmentShaderDeclarationAuxiliary();
5327
5328         template <glw::GLuint    D>
5329         static const glw::GLchar* FragmentShaderTail();
5330
5331         template <glw::GLuint D>
5332         static glw::GLenum      InputTextureTarget();
5333
5334         template <glw::GLuint D>
5335         void InputTextureImage(const glw::GLenum internal_format, const glw::GLuint width, const glw::GLuint height,
5336                                                    const glw::GLuint depth, const glw::GLenum format, const glw::GLenum type,
5337                                                    const glw::GLvoid* data);
5338
5339         template <typename T, glw::GLint S, bool N, glw::GLuint D>
5340         void CreateInputTexture();
5341
5342         template <typename T, glw::GLint S, bool N, glw::GLuint D>
5343         bool Check();
5344
5345         template <typename T, glw::GLint S, bool N, glw::GLuint D>
5346         bool Test();
5347
5348         template <typename T, bool N, glw::GLuint D>
5349         bool LoopTestOverS(bool skip_rgb);
5350
5351         template <typename T, bool N>
5352         bool LoopTestOverDOverS(bool skip_rgb);
5353
5354         template <glw::GLuint D>
5355         bool PrepareFramebufferMultisample(const glw::GLenum internal_format);
5356
5357         template <glw::GLuint D>
5358         void PrepareFramebufferAuxiliary(const glw::GLenum internal_format);
5359
5360         glw::GLuint PrepareProgram(const glw::GLchar* variable_declaration, const glw::GLchar* tail);
5361         void PrepareVertexArray();
5362
5363         template <glw::GLuint D>
5364         void                              Draw();
5365
5366         void CleanInputTexture();
5367         void CleanAuxiliaryTexture();
5368         void CleanFramebuffers();
5369         void CleanPrograms();
5370         void CleanErrors();
5371         void CleanVertexArray();
5372
5373         /* Private member variables. */
5374         glw::GLuint m_fbo_ms;
5375         glw::GLuint m_fbo_aux;
5376         glw::GLuint m_to_ms;
5377         glw::GLuint m_po_ms;
5378         glw::GLuint m_po_aux;
5379         glw::GLuint m_to;
5380         glw::GLuint m_to_aux;
5381         glw::GLuint m_vao;
5382
5383         /* Private static constants. */
5384         static const glw::GLchar* s_vertex_shader;
5385         static const glw::GLchar* s_fragment_shader_head;
5386         static const glw::GLchar* s_fragment_shader_ms_2D_fdecl_lowp;
5387         static const glw::GLchar* s_fragment_shader_ms_2D_idecl_lowp;
5388         static const glw::GLchar* s_fragment_shader_ms_2D_udecl_lowp;
5389         static const glw::GLchar* s_fragment_shader_ms_2D_fdecl_mediump;
5390         static const glw::GLchar* s_fragment_shader_ms_2D_idecl_mediump;
5391         static const glw::GLchar* s_fragment_shader_ms_2D_udecl_mediump;
5392         static const glw::GLchar* s_fragment_shader_ms_2D_fdecl_highp;
5393         static const glw::GLchar* s_fragment_shader_ms_2D_idecl_highp;
5394         static const glw::GLchar* s_fragment_shader_ms_2D_udecl_highp;
5395
5396         static const glw::GLchar* s_fragment_shader_ms_3D_fdecl_lowp;
5397         static const glw::GLchar* s_fragment_shader_ms_3D_idecl_lowp;
5398         static const glw::GLchar* s_fragment_shader_ms_3D_udecl_lowp;
5399         static const glw::GLchar* s_fragment_shader_ms_3D_fdecl_mediump;
5400         static const glw::GLchar* s_fragment_shader_ms_3D_idecl_mediump;
5401         static const glw::GLchar* s_fragment_shader_ms_3D_udecl_mediump;
5402         static const glw::GLchar* s_fragment_shader_ms_3D_fdecl_highp;
5403         static const glw::GLchar* s_fragment_shader_ms_3D_idecl_highp;
5404         static const glw::GLchar* s_fragment_shader_ms_3D_udecl_highp;
5405
5406         static const glw::GLchar* s_fragment_shader_aux_2D_fdecl_lowp;
5407         static const glw::GLchar* s_fragment_shader_aux_2D_idecl_lowp;
5408         static const glw::GLchar* s_fragment_shader_aux_2D_udecl_lowp;
5409         static const glw::GLchar* s_fragment_shader_aux_2D_fdecl_mediump;
5410         static const glw::GLchar* s_fragment_shader_aux_2D_idecl_mediump;
5411         static const glw::GLchar* s_fragment_shader_aux_2D_udecl_mediump;
5412         static const glw::GLchar* s_fragment_shader_aux_2D_fdecl_highp;
5413         static const glw::GLchar* s_fragment_shader_aux_2D_idecl_highp;
5414         static const glw::GLchar* s_fragment_shader_aux_2D_udecl_highp;
5415
5416         static const glw::GLchar* s_fragment_shader_aux_3D_fdecl_lowp;
5417         static const glw::GLchar* s_fragment_shader_aux_3D_idecl_lowp;
5418         static const glw::GLchar* s_fragment_shader_aux_3D_udecl_lowp;
5419         static const glw::GLchar* s_fragment_shader_aux_3D_fdecl_mediump;
5420         static const glw::GLchar* s_fragment_shader_aux_3D_idecl_mediump;
5421         static const glw::GLchar* s_fragment_shader_aux_3D_udecl_mediump;
5422         static const glw::GLchar* s_fragment_shader_aux_3D_fdecl_highp;
5423         static const glw::GLchar* s_fragment_shader_aux_3D_idecl_highp;
5424         static const glw::GLchar* s_fragment_shader_aux_3D_udecl_highp;
5425         static const glw::GLchar* s_fragment_shader_tail_2D;
5426         static const glw::GLchar* s_fragment_shader_tail_3D;
5427 };
5428 /* StorageMultisampleTest class */
5429
5430 /**  @class CompressedSubImage
5431  *
5432  *    Make test for following DSA functions:
5433  *        -  CompressedTextureSubImage1D,
5434  *        -  CompressedTextureSubImage2D,
5435  *        -  CompressedTextureSubImage3D.
5436  *
5437  *    Make test for following uncompressed internal formats:
5438  *        -  R8,
5439  *        -  R8_SNORM,
5440  *        -  R16,
5441  *        -  R16_SNORM,
5442  *        -  RG8,
5443  *        -  RG8_SNORM,
5444  *        -  RG16,
5445  *        -  RG16_SNORM,
5446  *        -  R3_G3_B2,
5447  *        -  RGB4,
5448  *        -  RGB5,
5449  *        -  RGB8,
5450  *        -  RGB8_SNORM,
5451  *        -  RGB10,
5452  *        -  RGB12,
5453  *        -  RGB16_SNORM,
5454  *        -  RGBA2,
5455  *        -  RGBA4,
5456  *        -  RGB5_A1,
5457  *        -  RGBA8,
5458  *        -  RGBA8_SNORM,
5459  *        -  RGB10_A2,
5460  *        -  RGB10_A2UI,
5461  *        -  RGBA12,
5462  *        -  RGBA16,
5463  *        -  SRGB8,
5464  *        -  SRGB8_ALPHA8,
5465  *        -  R16F,
5466  *        -  RG16F,
5467  *        -  RGB16F,
5468  *        -  RGBA16F,
5469  *        -  R32F,
5470  *        -  RG32F,
5471  *        -  RGB32F,
5472  *        -  RGBA32F,
5473  *        -  R11F_G11F_B10F,
5474  *        -  RGB9_E5,
5475  *        -  R8I,
5476  *        -  R8UI,
5477  *        -  R16I,
5478  *        -  R16UI,
5479  *        -  R32I,
5480  *        -  R32UI,
5481  *        -  RG8I,
5482  *        -  RG8UI,
5483  *        -  RG16I,
5484  *        -  RG16UI,
5485  *        -  RG32I,
5486  *        -  RG32UI,
5487  *        -  RGB8I,
5488  *        -  RGB8UI,
5489  *        -  RGB16I,
5490  *        -  RGB16UI,
5491  *        -  RGB32I,
5492  *        -  RGB32UI,
5493  *        -  RGBA8I,
5494  *        -  RGBA8UI,
5495  *        -  RGBA16I,
5496  *        -  RGBA16UI,
5497  *        -  RGBA32I,
5498  *        -  RGBA32UI.
5499  *    and compressed internal formats:
5500  *        -  COMPRESSED_RGBA8_ETC2_EAC.
5501  *
5502  *    Create texture and setup its storage and data using tested function with
5503  *    size 2x3 pixels.
5504  *
5505  *    Prepare framebuffer with renderbuffer color attachment with floating
5506  *    point internal format and with size 2x3 pixels
5507  *
5508  *    Prepare GLSL program with fragment shader which passes input texture to
5509  *    the framebuffer.
5510  *
5511  *    Draw a full screen quad with the prepared texture, program and
5512  *    framebuffer. Read the framebuffer content. Compare framebuffer's values
5513  *    with the reference values. Take normalization and precision into
5514  *    account. Expect equality.
5515  *
5516  *    Release all objects.
5517  */
5518 class CompressedSubImageTest : public deqp::TestCase
5519 {
5520 public:
5521         /* Public member functions. */
5522         CompressedSubImageTest(deqp::Context& context);
5523
5524         virtual tcu::TestNode::IterateResult iterate();
5525
5526 private:
5527         /* Private constructors. */
5528         CompressedSubImageTest(const CompressedSubImageTest& other);
5529         CompressedSubImageTest& operator=(const CompressedSubImageTest& other);
5530
5531         void CreateTextures(glw::GLenum target);
5532
5533         template <glw::GLuint D>
5534         glw::GLenum                       TextureTarget();
5535
5536         template <glw::GLuint D>
5537         void TextureImage(glw::GLint internalformat);
5538
5539         template <glw::GLuint D>
5540         void CompressedTexImage(glw::GLint internalformat);
5541
5542         template <glw::GLuint D>
5543         bool CompressedTextureSubImage(glw::GLint internalformat);
5544
5545         template <glw::GLuint D>
5546         void PrepareReferenceData(glw::GLenum internalformat);
5547
5548         template <glw::GLuint D>
5549         void PrepareStorage(glw::GLenum internalformat);
5550
5551         template <glw::GLuint D>
5552         bool CheckData(glw::GLenum internalformat);
5553         void            CleanAll();
5554         std::string DataToString(glw::GLuint count, const glw::GLubyte data[]);
5555
5556         template <glw::GLuint D>
5557         bool Test(glw::GLenum internalformat);
5558
5559         /* Private member variables. */
5560         glw::GLuint   m_to;
5561         glw::GLuint   m_to_aux;
5562         glw::GLubyte* m_compressed_texture_data;
5563         glw::GLubyte* m_reference;
5564         glw::GLubyte* m_result;
5565         glw::GLuint   m_reference_size;
5566         glw::GLuint   m_reference_internalformat;
5567
5568         /* Private static constants. */
5569         static const glw::GLubyte s_texture_data[];
5570         static const glw::GLuint  s_texture_width;
5571         static const glw::GLuint  s_texture_height;
5572         static const glw::GLuint  s_texture_depth;
5573         static const glw::GLuint  s_block_count;
5574         static const glw::GLuint  s_block_2d_size_x;
5575         static const glw::GLuint  s_block_2d_size_y;
5576         static const glw::GLuint  s_block_3d_size;
5577 };
5578 /* CompressedSubImageTest class */
5579
5580 /** @class CopyTest
5581  *
5582  *      Make test for following DSA functions:
5583  *       -  CopyTextureSubImage1D,
5584  *       -  CopyTextureSubImage2D and
5585  *       -  CopyTextureSubImage3D.
5586  *
5587  *      Prepare two textures 2x3x4 texels in size for corresponding directions
5588  *      (if available). Setup the first one with reference data.
5589  *
5590  *      Prepare framebuffer with the first texture attached to the a color
5591  *      attachment point. Bind the framebuffer.
5592  *
5593  *      Copy framebuffer content to the texture using tested function. The
5594  *      images shall be copied in ranges, two per direction (to test offsets,
5595  *      positions and size variables). For 3D textures copy each layer
5596  *      substituting the framebuffer attachment.
5597  *
5598  *      After the copy fetch texture data and compare it with the reference
5599  *      values. Expect equality.
5600  *
5601  *      Release all objects.
5602  */
5603 class CopyTest : public deqp::TestCase
5604 {
5605 public:
5606         /* Public member functions. */
5607         CopyTest(deqp::Context& context);
5608
5609         virtual tcu::TestNode::IterateResult iterate();
5610
5611 private:
5612         /* Private constructors. */
5613         CopyTest(const CopyTest& other);
5614         CopyTest& operator=(const CopyTest& other);
5615
5616         /* Private member functions. */
5617         template <glw::GLuint D>
5618         glw::GLenum                       TextureTarget();
5619
5620         bool CopyTextureSubImage1DAndCheckErrors(glw::GLuint texture, glw::GLint level, glw::GLint xoffset, glw::GLint x,
5621                                                                                          glw::GLint y, glw::GLsizei width);
5622         bool CopyTextureSubImage2DAndCheckErrors(glw::GLuint texture, glw::GLint level, glw::GLint xoffset,
5623                                                                                          glw::GLint yoffset, glw::GLint x, glw::GLint y, glw::GLsizei width,
5624                                                                                          glw::GLsizei height);
5625         bool CopyTextureSubImage3DAndCheckErrors(glw::GLuint texture, glw::GLint level, glw::GLint xoffset,
5626                                                                                          glw::GLint yoffset, glw::GLint zoffset, glw::GLint x, glw::GLint y,
5627                                                                                          glw::GLsizei width, glw::GLsizei height);
5628
5629         template <glw::GLuint D>
5630         void                              CreateSourceTexture();
5631
5632         template <glw::GLuint D>
5633         void                              CreateDestinationTexture();
5634
5635         template <glw::GLuint D>
5636         void                              CreateSourceFramebuffer();
5637
5638         template <glw::GLuint D>
5639         void                              CreateAll();
5640
5641         template <glw::GLuint D>
5642         bool                              Test();
5643
5644         bool CheckData(glw::GLenum target, glw::GLuint size);
5645         std::string DataToString(glw::GLuint count, const glw::GLubyte data[]);
5646         void CleanAll();
5647
5648         /* Private member variables. */
5649         glw::GLuint   m_fbo;
5650         glw::GLuint   m_to_src;
5651         glw::GLuint   m_to_dst;
5652         glw::GLubyte* m_result;
5653
5654         /* Private static constants. */
5655         static const glw::GLubyte s_texture_data[];
5656         static const glw::GLuint  s_texture_width;
5657         static const glw::GLuint  s_texture_height;
5658         static const glw::GLuint  s_texture_depth;
5659 };
5660 /* CopyTest class */
5661
5662 /** @class GetSetParameterTest
5663  *
5664  *  Do following:
5665  *      Prepare texture object.
5666  *
5667  *      Prepare the following test case.
5668  *
5669  *          Prepare test case which sets a parameter to the desired value using
5670  *          one of the following functions (depending on the parameter type):
5671  *           -  TextureParameterf,
5672  *           -  TextureParameterfv,
5673  *           -  TextureParameteri,
5674  *           -  TextureParameterIiv,
5675  *           -  TextureParameterIuiv,
5676  *           -  TextureParameteriv.
5677  *
5678  *          Read back the texture parameter using one of the DSA-like functions
5679  *           -  GetTextureParameterfv,
5680  *           -  GetTextureParameteriv,
5681  *           -  GetTextureParameterIiv,
5682  *           -  GetTextureParameterIuiv.
5683  *          Expect equality.
5684  *
5685  *      Run the test case for following parameters and values:
5686  *       -  parameter DEPTH_STENCIL_TEXTURE_MODE with value DEPTH_COMPONENT;
5687  *       -  parameter TEXTURE_BASE_LEVEL with value 2;
5688  *       -  parameter TEXTURE_BORDER_COLOR with value {0.25, 0.5, 0.75, 1.0}
5689  *       -  parameter TEXTURE_COMPARE_FUNC with value LEQUAL;
5690  *       -  parameter TEXTURE_COMPARE_MODE with value COMPARE_REF_TO_TEXTURE;
5691  *       -  parameter TEXTURE_LOD_BIAS with value -2.0 (which is
5692  *          minimum required implementation maximum value);
5693  *       -  parameter TEXTURE_MIN_FILTER with value LINEAR_MIPMAP_NEAREST;
5694  *       -  parameter TEXTURE_MAG_FILTER with value NEAREST;
5695  *       -  parameter TEXTURE_MIN_LOD with value -100;
5696  *       -  parameter TEXTURE_MAX_LOD with value 100;
5697  *       -  parameter TEXTURE_MAX_LEVEL with value 100;
5698  *       -  parameter TEXTURE_SWIZZLE_R with value BLUE;
5699  *       -  parameter TEXTURE_SWIZZLE_G with value ALPHA;
5700  *       -  parameter TEXTURE_SWIZZLE_B with value RED;
5701  *       -  parameter TEXTURE_SWIZZLE_A with value GREEN;
5702  *       -  parameter TEXTURE_SWIZZLE_RGBA with value { ZERO, ONE, ZERO, ONE };
5703  *       -  parameter TEXTURE_WRAP_S with value MIRROR_CLAMP_TO_EDGE;
5704  *       -  parameter TEXTURE_WRAP_T with value CLAMP_TO_EDGE;
5705  *       -  parameter TEXTURE_WRAP_R with value CLAMP_TO_EDGE.
5706  *
5707  *      Release the texture object.
5708  */
5709 class GetSetParameterTest : public deqp::TestCase
5710 {
5711 public:
5712         /* Public member functions. */
5713         GetSetParameterTest(deqp::Context& context);
5714
5715         virtual tcu::TestNode::IterateResult iterate();
5716
5717 private:
5718         /* Private constructors. */
5719         GetSetParameterTest(const GetSetParameterTest& other);
5720         GetSetParameterTest& operator=(const GetSetParameterTest& other);
5721
5722         bool CheckErrorAndLog(const glw::GLchar* fname, glw::GLenum pname);
5723         bool CompareAndLog(glw::GLint value_src, glw::GLint value_dst, glw::GLenum pname);
5724         bool CompareAndLog(glw::GLuint value_src, glw::GLuint value_dst, glw::GLenum pname);
5725         bool CompareAndLog(glw::GLfloat value_src, glw::GLfloat value_dst, glw::GLenum pname);
5726         bool CompareAndLog(glw::GLfloat value_src[4], glw::GLfloat value_dst[4], glw::GLenum pname);
5727         bool CompareAndLog(glw::GLint value_src[4], glw::GLint value_dst[4], glw::GLenum pname);
5728         bool CompareAndLog(glw::GLuint value_src[4], glw::GLuint value_dst[4], glw::GLenum pname);
5729 };
5730 /* GetSetParameterTest class */
5731
5732 /** @class DefaultsTest
5733  *
5734  *      Create texture object with CreateTextures. Do not bind it.
5735  *
5736  *      Using one of the functions
5737  *       -  GetTextureParameterfv,
5738  *       -  GetTextureParameteriv,
5739  *       -  GetTextureParameterIiv,
5740  *       -  GetTextureParameterIuiv
5741  *      check that initial object parameter values are set to the following
5742  *      defaults:
5743  *       -  for parameter DEPTH_STENCIL_TEXTURE_MODE initial value is
5744  *          DEPTH_COMPONENT;
5745  *       -  for parameter TEXTURE_BASE_LEVEL initial value is 0;
5746  *       -  for parameter TEXTURE_BORDER_COLOR initial value is {0.0, 0.0, 0.0,
5747  *          0.0};
5748  *       -  for parameter TEXTURE_COMPARE_FUNC initial value is LEQUAL;
5749  *       -  for parameter TEXTURE_COMPARE_MODE initial value is NONE;
5750  *       -  for parameter TEXTURE_LOD_BIAS initial value is 0.0;
5751  *       -  for parameter TEXTURE_MIN_FILTER initial value is
5752  *          NEAREST_MIPMAP_LINEAR;
5753  *       -  for parameter TEXTURE_MAG_FILTER initial value is LINEAR;
5754  *       -  for parameter TEXTURE_MIN_LOD initial value is -1000;
5755  *       -  for parameter TEXTURE_MAX_LOD initial value is 1000;
5756  *       -  for parameter TEXTURE_MAX_LEVEL initial value is 1000;
5757  *       -  for parameter TEXTURE_SWIZZLE_R initial value is RED;
5758  *       -  for parameter TEXTURE_SWIZZLE_G initial value is GREEN;
5759  *       -  for parameter TEXTURE_SWIZZLE_B initial value is BLUE;
5760  *       -  for parameter TEXTURE_SWIZZLE_A initial value is ALPHA;
5761  *       -  for parameter TEXTURE_WRAP_S initial value is REPEAT;
5762  *       -  for parameter TEXTURE_WRAP_T initial value is REPEAT;
5763  *       -  for parameter TEXTURE_WRAP_R initial value is REPEAT.
5764  */
5765 class DefaultsTest : public deqp::TestCase
5766 {
5767 public:
5768         /* Public member functions. */
5769         DefaultsTest(deqp::Context& context);
5770
5771         virtual tcu::TestNode::IterateResult iterate();
5772
5773 private:
5774         /* Private constructors. */
5775         DefaultsTest(const DefaultsTest& other);
5776         DefaultsTest& operator=(const DefaultsTest& other);
5777
5778         bool CompareAndLog(glw::GLint value_ref, glw::GLint value_dst, glw::GLenum pname);
5779         bool CompareAndLog(glw::GLuint value_ref, glw::GLuint value_dst, glw::GLenum pname);
5780         bool CompareAndLog(glw::GLfloat value_ref, glw::GLfloat value_dst, glw::GLenum pname);
5781         bool CompareAndLog(glw::GLfloat value_ref[4], glw::GLfloat value_dst[4], glw::GLenum pname);
5782         bool CompareAndLog(glw::GLint value_ref[4], glw::GLint value_dst[4], glw::GLenum pname);
5783         bool CompareAndLog(glw::GLuint value_ref[4], glw::GLuint value_dst[4], glw::GLenum pname);
5784 };
5785 /* DefaultsTest class */
5786
5787 /** @class GenerateMipmapTest
5788  *
5789  *      Create one dimensional texture. Setup its image data with successive
5790  *      numbers {0..255} stored as red color.
5791  *
5792  *      Generate mipmaps for the texture using GenerateTextureMipmap function.
5793  *
5794  *      Download each of the generated mipmap levels. Check that each of the
5795  *      mipmaps contains series of not decreasing values.
5796  *
5797  *      Release texture object.
5798  */
5799 class GenerateMipmapTest : public deqp::TestCase
5800 {
5801 public:
5802         /* Public member functions. */
5803         GenerateMipmapTest(deqp::Context& context);
5804
5805         virtual tcu::TestNode::IterateResult iterate();
5806
5807 private:
5808         /* Private constructors. */
5809         GenerateMipmapTest(const GenerateMipmapTest& other);
5810         GenerateMipmapTest& operator=(const GenerateMipmapTest& other);
5811
5812         /* Private static constants. */
5813         static const glw::GLubyte s_texture_data[];
5814         static const glw::GLuint  s_texture_width;
5815         static const glw::GLuint  s_texture_width_log;
5816 };
5817 /* GenerateMipmapTest class */
5818
5819 /** @class BindUnitTest
5820  *
5821  *      Create four 2D textures, filled with 2x3 texels of reference data in RED
5822  *      format and R8 internal format.
5823  *
5824  *      Create framebuffer 2x3 pixels of size with the same internal format as
5825  *      textures but RGBA format.
5826  *
5827  *      Bind each texture to the separate unit using BindTextureUnit function.
5828  *
5829  *      Prepare GLSL program which draws full screen quad. A fragment shader of
5830  *      the program shall pass each of the four input texture red values into
5831  *      separate RGBA channel of the output framebuffer.
5832  *
5833  *      Make a draw call with prepared objects.
5834  *
5835  *      Fetch framebuffer data. Expect interleaved reference data.
5836  *
5837  *      Release all objects.
5838  */
5839 class BindUnitTest : public deqp::TestCase
5840 {
5841 public:
5842         /* Public member functions. */
5843         BindUnitTest(deqp::Context& context);
5844
5845         virtual tcu::TestNode::IterateResult iterate();
5846
5847 private:
5848         /* Private constructors. */
5849         BindUnitTest(const BindUnitTest& other);
5850         BindUnitTest& operator=(const BindUnitTest& other);
5851
5852         void            CreateProgram();
5853         void            CreateTextures();
5854         void            CreateFrambuffer();
5855         void            CreateVertexArray();
5856         bool            Draw();
5857         bool            Check();
5858         void            CleanAll();
5859         std::string DataToString(glw::GLuint count, const glw::GLubyte data[]);
5860
5861         /* Private member variables. */
5862         glw::GLuint   m_po;
5863         glw::GLuint   m_to[4];
5864         glw::GLuint   m_fbo;
5865         glw::GLuint   m_rbo;
5866         glw::GLuint   m_vao;
5867         glw::GLubyte* m_result;
5868
5869         /* Private static constants. */
5870         static const glw::GLubyte s_texture_data_r[];
5871         static const glw::GLubyte s_texture_data_g[];
5872         static const glw::GLubyte s_texture_data_b[];
5873         static const glw::GLubyte s_texture_data_a[];
5874         static const glw::GLubyte s_texture_data_rgba[];
5875         static const glw::GLuint  s_texture_width;
5876         static const glw::GLuint  s_texture_height;
5877         static const glw::GLuint  s_texture_count_rgba;
5878         static const glw::GLchar* s_vertex_shader;
5879         static const glw::GLchar* s_fragment_shader;
5880         static const glw::GLchar* s_fragment_shader_samplers[4];
5881 };
5882 /* GenerateMipmapTest class */
5883
5884 /** @class GetImageTest
5885  *
5886  *          Make test for following DSA functions:
5887  *       -  GetTextureImage,
5888  *       -  GetCompressedTextureImage.
5889  *
5890  *      Create two 2D textures, one with compressed reference image, one with
5891  *      uncompressed reference image.
5892  *
5893  *      Fetch textures with corresponding test functions. Compare fetched values
5894  *      with the reference data. Expect equality.
5895  *
5896  *      Release textures.
5897  */
5898 class GetImageTest : public deqp::TestCase
5899 {
5900 public:
5901         /* Public member functions. */
5902         GetImageTest(deqp::Context& context);
5903
5904         virtual tcu::TestNode::IterateResult iterate();
5905
5906 private:
5907         /* Private constructors. */
5908         GetImageTest(const GetImageTest& other);
5909         GetImageTest& operator=(const GetImageTest& other);
5910
5911         std::string DataToString(glw::GLuint count, const glw::GLubyte data[]);
5912
5913         /* Private static constants. */
5914         static const glw::GLubyte s_texture_data[];
5915         static const glw::GLubyte s_texture_data_compressed[];
5916         static const glw::GLuint  s_texture_width;
5917         static const glw::GLuint  s_texture_height;
5918         static const glw::GLuint  s_texture_size;
5919         static const glw::GLuint  s_texture_size_compressed;
5920         static const glw::GLuint  s_texture_count;
5921         static const glw::GLuint  s_texture_count_compressed;
5922 };
5923 /* GetImageTest class */
5924
5925 /** @class GetLevelParameterTest
5926  *
5927  *      Make test for following DSA functions:
5928  *          -  GetTextureLevelParameterfv,
5929  *          -  GetTextureLevelParameteriv.
5930  *
5931  *      Create 3D texture with two levels of detail.
5932  *
5933  *      Fetch following parameters with test functions:
5934  *       -  TEXTURE_WIDTH,
5935  *       -  TEXTURE_HEIGHT,
5936  *       -  TEXTURE_DEPTH,
5937  *       -  TEXTURE_INTERNAL_FORMAT,
5938  *       -  TEXTURE_RED_TYPE,
5939  *       -  TEXTURE_GREEN_TYPE,
5940  *       -  TEXTURE_BLUE_TYPE,
5941  *       -  TEXTURE_ALPHA_TYPE,
5942  *       -  TEXTURE_DEPTH_TYPE,
5943  *       -  TEXTURE_RED_SIZE,
5944  *       -  TEXTURE_GREEN_SIZE,
5945  *       -  TEXTURE_BLUE_SIZE,
5946  *       -  TEXTURE_ALPHA_SIZE,
5947  *       -  TEXTURE_DEPTH_SIZE and
5948  *       -  TEXTURE_COMPRESSED
5949  *      and compare values with expected set.
5950  *
5951  *      Release texture.
5952  */
5953 class GetLevelParameterTest : public deqp::TestCase
5954 {
5955 public:
5956         /* Public member functions. */
5957         GetLevelParameterTest(deqp::Context& context);
5958
5959         virtual tcu::TestNode::IterateResult iterate();
5960
5961 private:
5962         /* Private constructors. */
5963         GetLevelParameterTest(const GetLevelParameterTest& other);
5964         GetLevelParameterTest& operator=(const GetLevelParameterTest& other);
5965
5966         /* Private static constants. */
5967         static const glw::GLubyte s_texture_data[];
5968         static const glw::GLuint  s_texture_width;
5969         static const glw::GLuint  s_texture_height;
5970         static const glw::GLuint  s_texture_depth;
5971 };
5972 /* GetLevelParameterTest class */
5973
5974 /** @class ErrorsUtilities
5975  *
5976  *      This class contain utility methods for all negative tests.
5977  */
5978 class ErrorsUtilities
5979 {
5980 public:
5981         bool CheckErrorAndLog(deqp::Context& context, glw::GLuint expected_error, const glw::GLchar* function_name,
5982                                                   const glw::GLchar* log);
5983 };
5984 /* ErrorsUtilities  */
5985
5986 /** @class CreationErrorsTest
5987  *
5988  *      Check that INVALID_ENUM is generated if target is not one of the
5989  *      allowable values.
5990  *
5991  *      Check that INVALID_VALUE is generated if n is negative.
5992  */
5993 class CreationErrorsTest : public deqp::TestCase, ErrorsUtilities
5994 {
5995 public:
5996         /* Public member functions. */
5997         CreationErrorsTest(deqp::Context& context);
5998
5999         virtual tcu::TestNode::IterateResult iterate();
6000
6001 private:
6002         /* Private constructors. */
6003         CreationErrorsTest(const CreationErrorsTest& other);
6004         CreationErrorsTest& operator=(const CreationErrorsTest& other);
6005
6006         glw::GLenum NotATarget();
6007 };
6008 /* CreationErrorsTest class */
6009
6010 /** @class BufferErrorsTest
6011  *
6012  *      Check that INVALID_OPERATION is generated by glTextureBuffer if texture
6013  *      is not the name of an existing texture object.
6014  *
6015  *      Check that INVALID_ENUM is generated by glTextureBuffer if the effective
6016  *      target of texture is not TEXTURE_BUFFER.
6017  *
6018  *      Check that INVALID_ENUM is generated if internalformat is not one of the
6019  *      sized internal formats described above.
6020  *
6021  *      Check that INVALID_OPERATION is generated if buffer is not zero and is
6022  *      not the name of an existing buffer object.
6023  */
6024 class BufferErrorsTest : public deqp::TestCase, ErrorsUtilities
6025 {
6026 public:
6027         /* Public member functions. */
6028         BufferErrorsTest(deqp::Context& context);
6029
6030         virtual tcu::TestNode::IterateResult iterate();
6031
6032 private:
6033         /* Private constructors. */
6034         BufferErrorsTest(const BufferErrorsTest& other);
6035         BufferErrorsTest& operator=(const BufferErrorsTest& other);
6036 };
6037 /* BufferErrorsTest class */
6038
6039 /** @class BufferRangeErrorsTest
6040  *
6041  *      Check that INVALID_OPERATION is generated by TextureBufferRange if
6042  *      texture is not the name of an existing texture object.
6043  *
6044  *      Check that INVALID_ENUM is generated by TextureBufferRange if the
6045  *      effective target of texture is not TEXTURE_BUFFER.
6046  *
6047  *      Check that INVALID_ENUM is generated by TextureBufferRange if
6048  *      internalformat is not one of the sized internal formats described above.
6049  *
6050  *      Check that INVALID_OPERATION is generated by TextureBufferRange if
6051  *      buffer is not zero and is not the name of an existing buffer object.
6052  *
6053  *      Check that INVALID_VALUE is generated by TextureBufferRange if offset
6054  *      is negative, if size is less than or equal to zero, or if offset + size
6055  *      is greater than the value of BUFFER_SIZE for buffer.
6056  *
6057  *      Check that INVALID_VALUE is generated by TextureBufferRange if offset is
6058  *      not an integer multiple of the value of TEXTURE_BUFFER_OFFSET_ALIGNMENT.
6059  */
6060 class BufferRangeErrorsTest : public deqp::TestCase, ErrorsUtilities
6061 {
6062 public:
6063         /* Public member functions. */
6064         BufferRangeErrorsTest(deqp::Context& context);
6065
6066         virtual tcu::TestNode::IterateResult iterate();
6067
6068 private:
6069         /* Private constructors. */
6070         BufferRangeErrorsTest(const BufferRangeErrorsTest& other);
6071         BufferRangeErrorsTest& operator=(const BufferRangeErrorsTest& other);
6072 };
6073 /* BufferErrorsTest class */
6074
6075 /** @class StorageErrorsTest
6076  *
6077  *      Check that INVALID_OPERATION is generated by TextureStorage1D if texture
6078  *      is not the name of an existing texture object.
6079  *
6080  *      Check that INVALID_ENUM is generated by TextureStorage1D if
6081  *      internalformat is not a valid sized internal format.
6082  *
6083  *      Check that INVALID_ENUM is generated by TextureStorage1D if target or
6084  *      the effective target of texture is not one of the accepted targets
6085  *      described above.
6086  *
6087  *      Check that INVALID_VALUE is generated by TextureStorage1D if width or
6088  *      levels are less than 1.
6089  *
6090  *      Check that INVALID_OPERATION is generated by TextureStorage1D if levels
6091  *      is greater than log2(width)+1.
6092  *
6093  *
6094  *      Check that INVALID_OPERATION is generated by TextureStorage2D if
6095  *      texture is not the name of an existing texture object.
6096  *
6097  *      Check that INVALID_ENUM is generated by TextureStorage2D if
6098  *      internalformat is not a valid sized internal format.
6099  *
6100  *      Check that INVALID_ENUM is generated by TextureStorage2D if target or
6101  *      the effective target of texture is not one of the accepted targets
6102  *      described above.
6103  *
6104  *      Check that INVALID_VALUE is generated by TextureStorage2D if width,
6105  *      height or levels are less than 1.
6106  *
6107  *      Check that INVALID_OPERATION is generated by TextureStorage2D if target
6108  *      is TEXTURE_1D_ARRAY or PROXY_TEXTURE_1D_ARRAY and levels is greater than
6109  *      log2(width)+1.
6110  *
6111  *      Check that INVALID_OPERATION is generated by TextureStorage2D if target
6112  *      is not TEXTURE_1D_ARRAY or PROXY_TEXTURE_1D_ARRAY and levels is greater
6113  *      than log2(max(width, height))+1.
6114  *
6115  *
6116  *      Check that INVALID_OPERATION is generated by TextureStorage2DMultisample
6117  *      if texture is not the name of an existing texture object.
6118  *
6119  *      Check that INVALID_ENUM is generated by TextureStorage2DMultisample if
6120  *      internalformat is not a valid color-renderable, depth-renderable or
6121  *      stencil-renderable format.
6122  *
6123  *      Check that INVALID_ENUM is generated by TextureStorage2DMultisample if
6124  *      target or the effective target of texture is not one of the accepted
6125  *      targets described above.
6126  *
6127  *      Check that INVALID_VALUE is generated by TextureStorage2DMultisample if
6128  *      width or height are less than 1 or greater than the value of
6129  *      MAX_TEXTURE_SIZE.
6130  *
6131  *
6132  *      Check that INVALID_VALUE is generated by TextureStorage2DMultisample if
6133  *      samples is greater than the value of MAX_SAMPLES.
6134  *
6135  *      Check that INVALID_OPERATION is generated by TextureStorage2DMultisample
6136  *      if the value of TEXTURE_IMMUTABLE_FORMAT for the texture bound to target
6137  *      is not FALSE.
6138  *
6139  *
6140  *      Check that INVALID_OPERATION is generated by TextureStorage3D if texture
6141  *      is not the name of an existing texture object.
6142  *
6143  *      Check that INVALID_ENUM is generated by TextureStorage3D if
6144  *      internalformat is not a valid sized internal format.
6145  *
6146  *      Check that INVALID_ENUM is generated by TextureStorage3D if target or
6147  *      the effective target of texture is not one of the accepted targets
6148  *      described above.
6149  *
6150  *      Check that INVALID_VALUE is generated by TextureStorage3D if width,
6151  *      height, depth or levels are less than 1.
6152  *
6153  *      Check that INVALID_OPERATION is generated by TextureStorage3D if target
6154  *      is TEXTURE_3D or PROXY_TEXTURE_3D and levels is greater than
6155  *      log2(max(width, height, depth))+1.
6156  *
6157  *      Check that INVALID_OPERATION is generated by TextureStorage3D if target
6158  *      is TEXTURE_2D_ARRAY, PROXY_TEXTURE_2D_ARRAY, TEXURE_CUBE_ARRAY,
6159  *      or PROXY_TEXTURE_CUBE_MAP_ARRAY and levels is greater than
6160  *      log2(max(width, height))+1.
6161  *
6162  *
6163  *      Check that INVALID_OPERATION is generated by TextureStorage3DMultisample
6164  *      if texture is not the name of an existing texture object.
6165  *
6166  *      Check that INVALID_ENUM is generated by TextureStorage3DMultisample if
6167  *      internalformat is not a valid color-renderable, depth-renderable or
6168  *      stencil-renderable format.
6169  *
6170  *      Check that INVALID_ENUM is generated by TextureStorage3DMultisample if
6171  *      target or the effective target of texture is not one of the accepted
6172  *      targets described above.
6173  *
6174  *      Check that INVALID_VALUE is generated by TextureStorage3DMultisample if
6175  *      width or height are less than 1 or greater than the value of
6176  *      MAX_TEXTURE_SIZE.
6177  *
6178  *      Check that INVALID_VALUE is generated by TextureStorage3DMultisample if
6179  *      depth is less than 1 or greater than the value of
6180  *      MAX_ARRAY_TEXTURE_LAYERS.
6181  *
6182  *      Check that INVALID_VALUE is generated by TextureStorage3DMultisample if
6183  *      samples is greater than the value of MAX_SAMPLES.
6184  *
6185  *      Check that INVALID_OPERATION is generated by TextureStorage3DMultisample
6186  *      if the value of TEXTURE_IMMUTABLE_FORMAT for the texture bound to
6187  *      target is not FALSE.
6188  */
6189 class StorageErrorsTest : public deqp::TestCase, ErrorsUtilities
6190 {
6191 public:
6192         /* Public member functions. */
6193         StorageErrorsTest(deqp::Context& context);
6194
6195         virtual tcu::TestNode::IterateResult iterate();
6196
6197 private:
6198         /* Private constructors. */
6199         StorageErrorsTest(const StorageErrorsTest& other);
6200         StorageErrorsTest& operator=(const StorageErrorsTest& other);
6201
6202         glw::GLuint m_to_1D;
6203         glw::GLuint m_to_1D_array;
6204         glw::GLuint m_to_2D;
6205         glw::GLuint m_to_2D_array;
6206         glw::GLuint m_to_3D;
6207         glw::GLuint m_to_2D_ms;
6208         glw::GLuint m_to_2D_ms_immutable;
6209         glw::GLuint m_to_3D_ms;
6210         glw::GLuint m_to_3D_ms_immutable;
6211         glw::GLuint m_to_invalid;
6212         glw::GLuint m_internalformat_invalid;
6213         glw::GLint  m_max_texture_size;
6214         glw::GLint  m_max_samples;
6215         glw::GLint  m_max_array_texture_layers;
6216
6217         void Prepare();
6218         bool Test1D();
6219         bool Test2D();
6220         bool Test3D();
6221         bool Test2DMultisample();
6222         bool Test3DMultisample();
6223         void Clean();
6224 };
6225 /* StorageErrorsTest class */
6226
6227 /** @class SubImageErrorsTest
6228  *
6229  *          Check that INVALID_OPERATION is generated by TextureSubImage1D if
6230  *          texture is not the name of an existing texture object.
6231  *
6232  *          Check that INVALID_ENUM is generated by TextureSubImage1D if format is
6233  *          not an accepted format constant.
6234  *
6235  *          Check that INVALID_ENUM is generated by TextureSubImage1D if type is not
6236  *          a type constant.
6237  *
6238  *          Check that INVALID_VALUE is generated by TextureSubImage1D if level is
6239  *          less than 0.
6240  *
6241  *          Check that INVALID_VALUE may be generated by TextureSubImage1D if level
6242  *          is greater than log2 max, where max is the returned value of
6243  *          MAX_TEXTURE_SIZE.
6244  *
6245  *          Check that INVALID_VALUE is generated by TextureSubImage1D if
6246  *          xoffset<â�’b, or if (xoffset+width)>(wâ�’b), where w is the TEXTURE_WIDTH,
6247  *          and b is the width of the TEXTURE_BORDER of the texture image being
6248  *          modified. Note that w includes twice the border width.
6249  *          Check that INVALID_VALUE is generated by TextureSubImage1D if width is
6250  *          less than 0.
6251  *
6252  *          Check that INVALID_OPERATION is generated by TextureSubImage1D if type
6253  *          is one of UNSIGNED_BYTE_3_3_2, UNSIGNED_BYTE_2_3_3_REV,
6254  *          UNSIGNED_SHORT_5_6_5, or UNSIGNED_SHORT_5_6_5_REV and format is not RGB.
6255  *
6256  *          Check that INVALID_OPERATION is generated by TextureSubImage1D if type
6257  *          is one of UNSIGNED_SHORT_4_4_4_4, UNSIGNED_SHORT_4_4_4_4_REV,
6258  *          UNSIGNED_SHORT_5_5_5_1, UNSIGNED_SHORT_1_5_5_5_REV,
6259  *          UNSIGNED_INT_8_8_8_8, UNSIGNED_INT_8_8_8_8_REV, UNSIGNED_INT_10_10_10_2,
6260  *          or UNSIGNED_INT_2_10_10_10_REV and format is neither RGBA nor BGRA.
6261  *
6262  *          Check that INVALID_OPERATION is generated by TextureSubImage1D if a
6263  *          non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
6264  *          and the buffer object's data store is currently mapped.
6265  *
6266  *          Check that INVALID_OPERATION is generated by TextureSubImage1D if a
6267  *          non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
6268  *          and the data would be unpacked from the buffer object such that the
6269  *          memory reads required would exceed the data store size.
6270  *
6271  *          Check that INVALID_OPERATION is generated by TextureSubImage1D if a
6272  *          non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
6273  *          and pixels is not evenly divisible into the number of bytes needed to
6274  *          store in memory a datum indicated by type.
6275  *
6276  *
6277  *          Check that INVALID_OPERATION is generated by TextureSubImage2D if
6278  *          texture is not the name of an existing texture object.
6279  *
6280  *          Check that INVALID_ENUM is generated by TextureSubImage2D if format is
6281  *          not an accepted format constant.
6282  *
6283  *          Check that INVALID_ENUM is generated if type is not a type constant.
6284  *
6285  *          Check that INVALID_VALUE is generated by TextureSubImage2D if level is
6286  *          less than 0.
6287  *
6288  *          Check that INVALID_VALUE may be generated by TextureSubImage2D if level
6289  *          is greater than log2 max, where max is the returned value of
6290  *          MAX_TEXTURE_SIZE.
6291  *          Check that INVALID_VALUE is generated by TextureSubImage2D if
6292  *          xoffset<â�’b, (xoffset+width)>(wâ�’b), yoffset<â�’b, or
6293  *          (yoffset+height)>(hâ�’b), where w is the TEXTURE_WIDTH, h is the
6294  *          TEXTURE_HEIGHT, and b is the border width of the texture image being
6295  *          modified. Note that w and h include twice the border width.
6296  *          Check that INVALID_VALUE is generated by TextureSubImage2D if width or
6297  *          height is less than 0.
6298  *
6299  *          Check that INVALID_OPERATION is generated by TextureSubImage2D if type
6300  *          is one of UNSIGNED_BYTE_3_3_2, UNSIGNED_BYTE_2_3_3_REV,
6301  *          UNSIGNED_SHORT_5_6_5, or UNSIGNED_SHORT_5_6_5_REV and format is not RGB.
6302  *
6303  *          Check that INVALID_OPERATION is generated by TextureSubImage2D if type
6304  *          is one of UNSIGNED_SHORT_4_4_4_4, UNSIGNED_SHORT_4_4_4_4_REV,
6305  *          UNSIGNED_SHORT_5_5_5_1, UNSIGNED_SHORT_1_5_5_5_REV, UNSIGNED_INT_8_8_8_8,
6306  *          UNSIGNED_INT_8_8_8_8_REV, UNSIGNED_INT_10_10_10_2, or
6307  *          UNSIGNED_INT_2_10_10_10_REV and format is neither RGBA
6308  *          nor BGRA.
6309  *
6310  *          Check that INVALID_OPERATION is generated by TextureSubImage2D if a
6311  *          non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
6312  *          and the buffer object's data store is currently mapped.
6313  *
6314  *          Check that INVALID_OPERATION is generated by TextureSubImage2D if a
6315  *          non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
6316  *          and the data would be unpacked from the buffer object such that the
6317  *          memory reads required would exceed the data store size.
6318  *
6319  *          Check that INVALID_OPERATION is generated by TextureSubImage2D if a
6320  *          non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
6321  *          and pixels is not evenly divisible into the number of bytes needed to
6322  *          store in memory a datum indicated by type.
6323  *
6324  *
6325  *          Check that INVALID_OPERATION is generated by TextureSubImage3D if
6326  *          texture is not the name of an existing texture object.
6327  *
6328  *          Check that INVALID_ENUM is generated by TextureSubImage3D if format is
6329  *          not an accepted format constant.
6330  *
6331  *          Check that INVALID_ENUM is generated by TextureSubImage3D if type is
6332  *          not a type constant.
6333  *
6334  *          Check that INVALID_VALUE is generated by TextureSubImage3D if level
6335  *          is less than 0.
6336  *
6337  *          Check that INVALID_VALUE may be generated by TextureSubImage3D if level
6338  *          is greater than log2 max, where max is the returned value of
6339  *          MAX_TEXTURE_SIZE.
6340  *
6341  *          Check that INVALID_VALUE is generated by TextureSubImage3D if
6342  *          xoffset<â�’b, (xoffset+width)>(wâ�’b), yoffset<â�’b, or
6343  *          (yoffset+height)>(hâ�’b), or zoffset<â�’b, or (zoffset+depth)>(dâ�’b), where w
6344  *          is the TEXTURE_WIDTH, h is the TEXTURE_HEIGHT, d is the TEXTURE_DEPTH
6345  *          and b is the border width of the texture image being modified. Note
6346  *          that w, h, and d include twice the border width.
6347  *
6348  *          Check that INVALID_VALUE is generated by TextureSubImage3D if width,
6349  *          height, or depth is less than 0.
6350  *
6351  *          Check that INVALID_OPERATION is generated by TextureSubImage3D if type
6352  *          is one of UNSIGNED_BYTE_3_3_2, UNSIGNED_BYTE_2_3_3_REV,
6353  *          UNSIGNED_SHORT_5_6_5, or UNSIGNED_SHORT_5_6_5_REV and format is not RGB.
6354  *
6355  *          Check that INVALID_OPERATION is generated by TextureSubImage3D if type
6356  *          is one of UNSIGNED_SHORT_4_4_4_4, UNSIGNED_SHORT_4_4_4_4_REV,
6357  *          UNSIGNED_SHORT_5_5_5_1, UNSIGNED_SHORT_1_5_5_5_REV,
6358  *          UNSIGNED_INT_8_8_8_8, UNSIGNED_INT_8_8_8_8_REV, UNSIGNED_INT_10_10_10_2,
6359  *          or UNSIGNED_INT_2_10_10_10_REV and format is neither RGBA nor BGRA.
6360  *
6361  *          Check that INVALID_OPERATION is generated by TextureSubImage3D if a
6362  *          non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
6363  *          and the buffer object's data store is currently mapped.
6364  *
6365  *          Check that INVALID_OPERATION is generated by TextureSubImage3D if a
6366  *          non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
6367  *          and the data would be unpacked from the buffer object such that the
6368  *          memory reads required would exceed the data store size.
6369  *
6370  *          Check that INVALID_OPERATION is generated by TextureSubImage3D if a
6371  *          non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
6372  *          and pixels is not evenly divisible into the number of bytes needed to
6373  *          store in memory a datum indicated by type.
6374  *
6375  *
6376  *          Check that INVALID_ENUM is generated by CompressedTextureSubImage1D if
6377  *          internalformat is not one of the generic compressed internal formats:
6378  *          COMPRESSED_RED, COMPRESSED_RG, COMPRESSED_RGB, COMPRESSED_RGBA.
6379  *          COMPRESSED_SRGB, or COMPRESSED_SRGB_ALPHA.
6380  *
6381  *          Check that INVALID_VALUE is generated by CompressedTextureSubImage1D if
6382  *          imageSize is not consistent with the format, dimensions, and contents of
6383  *          the specified compressed image data.
6384  *
6385  *          Check that INVALID_OPERATION is generated by CompressedTextureSubImage1D
6386  *          if parameter combinations are not supported by the specific compressed
6387  *          internal format as specified in the specific texture compression
6388  *          extension.
6389  *
6390  *          Check that INVALID_OPERATION is generated by CompressedTextureSubImage1D
6391  *          if a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER
6392  *          target and the buffer object's data store is currently mapped.
6393  *
6394  *          Check that INVALID_OPERATION is generated by CompressedTextureSubImage1D
6395  *          if a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER
6396  *          target and the data would be unpacked from the buffer object such that
6397  *          the memory reads required would exceed the data store size.
6398  *
6399  *          Check that INVALID_OPERATION is generated by CompressedTextureSubImage1D
6400  *          function if texture is not the name of an existing texture object.
6401  *
6402  *
6403  *          Check that INVALID_OPERATION is generated by CompressedTextureSubImage2D
6404  *          if texture is not the name of an existing texture object.
6405  *
6406  *          Check that INVALID_ENUM is generated by CompressedTextureSubImage2D if
6407  *          internalformat is of the generic compressed internal formats:
6408  *          COMPRESSED_RED, COMPRESSED_RG, COMPRESSED_RGB, COMPRESSED_RGBA.
6409  *          COMPRESSED_SRGB, or COMPRESSED_SRGB_ALPHA.
6410  *
6411  *          Check that INVALID_OPERATION is generated by CompressedTextureSubImage2D
6412  *          if format does not match the internal format of the texture image being
6413  *          modified, since these commands do not provide for image format
6414  *          conversion.
6415  *
6416  *          Check that INVALID_VALUE is generated by CompressedTextureSubImage2D if
6417  *          imageSize is not consistent with the format, dimensions, and contents of
6418  *          the specified compressed image data.
6419  *
6420  *          Check that INVALID_OPERATION is generated by CompressedTextureSubImage2D
6421  *          if a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER
6422  *          target and the buffer object's data store is currently mapped.
6423  *
6424  *          Check that INVALID_OPERATION is generated by CompressedTextureSubImage2D
6425  *          if a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER
6426  *          target and the data would be unpacked from the buffer object such that
6427  *          the memory reads required would exceed the data store size.
6428  *
6429  *          Check that INVALID_OPERATION is generated by CompressedTextureSubImage2D
6430  *          if the effective target is TEXTURE_RECTANGLE.
6431  *
6432  *
6433  *          Check that INVALID_OPERATION is generated by CompressedTextureSubImage3D
6434  *          if texture is not the name of an existing texture object.
6435  *
6436  *          Check that INVALID_ENUM is generated by CompressedTextureSubImage3D if
6437  *          internalformat is one of the generic compressed internal formats:
6438  *          COMPRESSED_RED, COMPRESSED_RG, COMPRESSED_RGB, COMPRESSED_RGBA.
6439  *          COMPRESSED_SRGB, or COMPRESSED_SRGB_ALPHA.
6440  *
6441  *          Check that INVALID_OPERATION is generated by CompressedTextureSubImage3D
6442  *          if format does not match the internal format of the texture image being
6443  *          modified, since these commands do not provide for image format
6444  *          conversion.
6445  *
6446  *          Check that INVALID_VALUE is generated by CompressedTextureSubImage3D if
6447  *          imageSize is not consistent with the format, dimensions, and contents of
6448  *          the specified compressed image data.
6449  *
6450  *          Check that INVALID_OPERATION is generated by CompressedTextureSubImage3D
6451  *          if a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER
6452  *          target and the buffer object's data store is currently mapped.
6453  *
6454  *          Check that INVALID_OPERATION is generated by CompressedTextureSubImage3D
6455  *          if a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER
6456  *          target and the data would be unpacked from the buffer object such that
6457  *          the memory reads required would exceed the data store size.
6458  */
6459 class SubImageErrorsTest : public deqp::TestCase, ErrorsUtilities
6460 {
6461 public:
6462         /* Public member functions. */
6463         SubImageErrorsTest(deqp::Context& context);
6464
6465         virtual tcu::TestNode::IterateResult iterate();
6466
6467 private:
6468         /* Private constructors. */
6469         SubImageErrorsTest(const SubImageErrorsTest& other);
6470         SubImageErrorsTest& operator=(const SubImageErrorsTest& other);
6471
6472         glw::GLuint   m_to_1D_empty;
6473         glw::GLuint   m_to_2D_empty;
6474         glw::GLuint   m_to_3D_empty;
6475         glw::GLuint   m_to_1D;
6476         glw::GLuint   m_to_2D;
6477         glw::GLuint   m_to_3D;
6478         glw::GLuint   m_to_1D_compressed;
6479         glw::GLuint   m_to_2D_compressed;
6480         glw::GLuint   m_to_3D_compressed;
6481         glw::GLuint   m_to_rectangle_compressed;
6482         glw::GLuint   m_to_invalid;
6483         glw::GLuint   m_bo;
6484         glw::GLuint   m_format_invalid;
6485         glw::GLuint   m_type_invalid;
6486         glw::GLint      m_max_texture_size;
6487         glw::GLubyte* m_reference_compressed_1D;
6488         glw::GLubyte* m_reference_compressed_2D;
6489         glw::GLubyte* m_reference_compressed_3D;
6490         glw::GLubyte* m_reference_compressed_rectangle;
6491         glw::GLint      m_reference_compressed_1D_size;
6492         glw::GLint      m_reference_compressed_2D_size;
6493         glw::GLint      m_reference_compressed_3D_size;
6494         glw::GLint      m_reference_compressed_rectangle_size;
6495         glw::GLint      m_reference_compressed_1D_format;
6496         glw::GLint      m_reference_compressed_2D_format;
6497         glw::GLint      m_reference_compressed_3D_format;
6498         glw::GLint      m_reference_compressed_rectangle_format;
6499         glw::GLint      m_not_matching_compressed_1D_format;
6500         glw::GLint      m_not_matching_compressed_1D_size;
6501         glw::GLint      m_not_matching_compressed_2D_format;
6502         glw::GLint      m_not_matching_compressed_2D_size;
6503         glw::GLint      m_not_matching_compressed_3D_format;
6504         glw::GLint      m_not_matching_compressed_3D_size;
6505
6506         void Prepare();
6507         bool Test1D();
6508         bool Test2D();
6509         bool Test3D();
6510         bool Test1DCompressed();
6511         bool Test2DCompressed();
6512         bool Test3DCompressed();
6513         void Clean();
6514
6515         static const glw::GLushort s_reference[];
6516         static const glw::GLuint   s_reference_width;
6517         static const glw::GLuint   s_reference_height;
6518         static const glw::GLuint   s_reference_depth;
6519         static const glw::GLuint   s_reference_size;
6520         static const glw::GLenum   s_reference_internalformat;
6521         static const glw::GLenum   s_reference_internalformat_compressed;
6522         static const glw::GLenum   s_reference_format;
6523         static const glw::GLenum   s_reference_type;
6524 };
6525 /* SubImageErrorsTest class */
6526
6527 /** @class CopyErrorsTest
6528  *
6529  *          Check that INVALID_FRAMEBUFFER_OPERATION is generated by
6530  *          CopyTextureSubImage1D if the object bound to READ_FRAMEBUFFER_BINDING is
6531  *          not framebuffer complete.
6532  *
6533  *          Check that INVALID_OPERATION is generated by CopyTextureSubImage1D if
6534  *          texture is not the name of an existing texture object, or if the
6535  *          effective target of texture is not TEXTURE_1D.
6536  *
6537  *          Check that INVALID_VALUE is generated by CopyTextureSubImage1D if level
6538  *          is less than 0.
6539  *
6540  *          Check that INVALID_VALUE is generated by CopyTextureSubImage1D if
6541  *          xoffset<0, or (xoffset+width)>w, where w is the TEXTURE_WIDTH of the
6542  *          texture image being modified.
6543  *
6544  *          Check that INVALID_OPERATION is generated by CopyTextureSubImage1D if
6545  *          the read buffer is NONE, or the value of READ_FRAMEBUFFER_BINDING is
6546  *          non-zero, and: the read buffer selects an attachment that has no image
6547  *          attached, or the effective value of SAMPLE_BUFFERS for the read
6548  *          framebuffer is one.
6549  *
6550  *
6551  *          Check that INVALID_FRAMEBUFFER_OPERATION is generated by
6552  *          CopyTextureSubImage2D if the object bound to READ_FRAMEBUFFER_BINDING is
6553  *          not framebuffer complete.
6554  *
6555  *          Check that INVALID_OPERATION is generated by CopyTextureSubImage2D if
6556  *          texture is not the name of an existing texture object.
6557  *
6558  *          Check that INVALID_OPERATION is generated by CopyTextureSubImage2D if
6559  *          the effective target of texture does not correspond to one of the
6560  *          texture targets supported by the function.
6561  *
6562  *          Check that INVALID_VALUE is generated by CopyTextureSubImage2D if level
6563  *          is less than 0.
6564  *
6565  *          Check that INVALID_VALUE is generated by CopyTextureSubImage2D if
6566  *          xoffset<0, (xoffset+width)>w, yoffset<0, or (yoffset+height)>0, where w
6567  *          is the TEXTURE_WIDTH, h is the TEXTURE_HEIGHT and of the texture image
6568  *          being modified.
6569  *
6570  *          Check that INVALID_OPERATION is generated by CopyTextureSubImage2D if:
6571  *          the read buffer is NONE, or the value of READ_FRAMEBUFFER_BINDING is
6572  *          non-zero, and: the read buffer selects an attachment that has no image
6573  *          attached, or the effective value of SAMPLE_BUFFERS for the read
6574  *          framebuffer is one.
6575  *
6576  *
6577  *          Check that INVALID_OPERATION is generated by CopyTextureSubImage3D if
6578  *          the effective target is not TEXTURE_3D, TEXTURE_2D_ARRAY,
6579  *          TEXTURE_CUBE_MAP_ARRAY or TEXTURE_CUBE_MAP.
6580  *
6581  *          Check that INVALID_FRAMEBUFFER_OPERATION is generated by
6582  *          CopyTextureSubImage3D if the object bound to READ_FRAMEBUFFER_BINDING is
6583  *          not framebuffer complete.
6584  *
6585  *          Check that INVALID_OPERATION is generated by CopyTextureSubImage3D if
6586  *          texture is not the name of an existing texture object.
6587  *
6588  *          Check that INVALID_VALUE is generated by CopyTextureSubImage3D if level
6589  *          is less than 0.
6590  *
6591  *          Check that INVALID_VALUE is generated by CopyTextureSubImage3D if
6592  *          xoffset<0, (xoffset+width)>w, yoffset<0, (yoffset+height)>h, zoffset<0,
6593  *          or (zoffset+1)>d, where w is the TEXTURE_WIDTH, h is the TEXTURE_HEIGHT,
6594  *          d is the TEXTURE_DEPTH and of the texture image being modified. Note
6595  *          that w, h, and d include twice the border width.
6596  *
6597  *          Check that INVALID_OPERATION is generated by CopyTextureSubImage3D if:
6598  *          the read buffer is NONE, or the value of READ_FRAMEBUFFER_BINDING is
6599  *          non-zero, and: the read buffer selects an attachment that has no image
6600  *          attached, or the effective value of SAMPLE_BUFFERS for the read
6601  *          framebuffer is one.
6602  */
6603 class CopyErrorsTest : public deqp::TestCase, ErrorsUtilities
6604 {
6605 public:
6606         /* Public member functions. */
6607         CopyErrorsTest(deqp::Context& context);
6608
6609         virtual tcu::TestNode::IterateResult iterate();
6610
6611 private:
6612         /* Private constructors. */
6613         CopyErrorsTest(const CopyErrorsTest& other);
6614         CopyErrorsTest& operator=(const CopyErrorsTest& other);
6615
6616         glw::GLuint m_fbo;
6617         glw::GLuint m_fbo_ms;
6618         glw::GLuint m_fbo_incomplete;
6619         glw::GLuint m_to_src;
6620         glw::GLuint m_to_src_ms;
6621         glw::GLuint m_to_1D_dst;
6622         glw::GLuint m_to_2D_dst;
6623         glw::GLuint m_to_3D_dst;
6624         glw::GLuint m_to_invalid;
6625
6626         void Prepare();
6627         bool Test1D();
6628         bool Test2D();
6629         bool Test3D();
6630         void Clean();
6631
6632         static const glw::GLuint s_width;
6633         static const glw::GLuint s_height;
6634         static const glw::GLuint s_depth;
6635         static const glw::GLuint s_internalformat;
6636 };
6637 /* CopyErrorsTest class */
6638
6639 /** @class ParameterSetupErrorsTest
6640  *
6641  *      Check that INVALID_ENUM is generated by TextureParameter* if pname is
6642  *      not one of the accepted defined values.
6643  *
6644  *      Check that INVALID_ENUM is generated by TextureParameter* if params
6645  *      should have a defined constant value (based on the value of pname) and
6646  *       does not.
6647  *
6648  *      Check that INVALID_ENUM is generated if TextureParameter{if} is called
6649  *      for a non-scalar parameter (pname TEXTURE_BORDER_COLOR or
6650  *      TEXTURE_SWIZZLE_RGBA).
6651  *
6652  *      Check that INVALID_ENUM is generated by TextureParameter* if the
6653  *      effective target is either TEXTURE_2D_MULTISAMPLE or
6654  *      TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states.
6655  *
6656  *      Check that INVALID_ENUM is generated by TextureParameter* if the
6657  *      effective target is TEXTURE_RECTANGLE and either of pnames
6658  *      TEXTURE_WRAP_S or TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE,
6659  *      MIRRORED_REPEAT or REPEAT.
6660  *
6661  *      Check that INVALID_ENUM is generated by TextureParameter* if the
6662  *      effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is
6663  *      set to a value other than NEAREST or LINEAR (no mipmap filtering is
6664  *      permitted).
6665  *
6666  *      Check that INVALID_OPERATION is generated by TextureParameter* if the
6667  *      effective target is either TEXTURE_2D_MULTISAMPLE or
6668  *      TEXTURE_2D_MULTISAMPLE_ARRAY, and pname TEXTURE_BASE_LEVEL is set to a
6669  *      value other than zero.
6670  *
6671  *      Check that INVALID_OPERATION is generated by TextureParameter* if
6672  *      texture is not the name of an existing texture object.
6673  *
6674  *      Check that INVALID_OPERATION is generated by TextureParameter* if the
6675  *      effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is
6676  *      set to any value other than zero.
6677  *
6678  *      Check that INVALID_VALUE is generated by TextureParameter* if pname is
6679  *      TEXTURE_BASE_LEVEL or TEXTURE_MAX_LEVEL, and param or params is
6680  *      negative.
6681  */
6682 class ParameterSetupErrorsTest : public deqp::TestCase, ErrorsUtilities
6683 {
6684 public:
6685         /* Public member functions. */
6686         ParameterSetupErrorsTest(deqp::Context& context);
6687
6688         virtual tcu::TestNode::IterateResult iterate();
6689
6690 private:
6691         /* Private constructors. */
6692         ParameterSetupErrorsTest(const ParameterSetupErrorsTest& other);
6693         ParameterSetupErrorsTest& operator=(const ParameterSetupErrorsTest& other);
6694
6695         glw::GLuint m_to_2D;
6696         glw::GLuint m_to_2D_ms;
6697         glw::GLuint m_to_rectangle;
6698         glw::GLuint m_to_invalid;
6699         glw::GLenum m_pname_invalid;
6700         glw::GLenum m_depth_stencil_mode_invalid;
6701
6702         void Prepare();
6703         bool Testf();
6704         bool Testi();
6705         bool Testfv();
6706         bool Testiv();
6707         bool TestIiv();
6708         bool TestIuiv();
6709         void Clean();
6710
6711         static const glw::GLuint s_width;
6712         static const glw::GLuint s_height;
6713         static const glw::GLuint s_depth;
6714         static const glw::GLuint s_internalformat;
6715 };
6716 /* ParameterSetupErrorsTest class */
6717
6718 /** @class GenerateMipmapErrorsTest
6719  *
6720  *      Check that INVALID_OPERATION is generated by GenerateTextureMipmap if
6721  *      texture is not the name of an existing texture object.
6722  *
6723  *      Check that INVALID_OPERATION is generated by GenerateTextureMipmap if
6724  *      target is TEXTURE_CUBE_MAP or TEXTURE_CUBE_MAP_ARRAY, and the specified
6725  *      texture object is not cube complete or cube array complete,
6726  *      respectively.
6727  */
6728 class GenerateMipmapErrorsTest : public deqp::TestCase, ErrorsUtilities
6729 {
6730 public:
6731         /* Public member functions. */
6732         GenerateMipmapErrorsTest(deqp::Context& context);
6733
6734         virtual tcu::TestNode::IterateResult iterate();
6735
6736 private:
6737         /* Private constructors. */
6738         GenerateMipmapErrorsTest(const GenerateMipmapErrorsTest& other);
6739         GenerateMipmapErrorsTest& operator=(const GenerateMipmapErrorsTest& other);
6740
6741         static const glw::GLubyte s_reference_data[];
6742         static const glw::GLuint  s_reference_width;
6743         static const glw::GLuint  s_reference_height;
6744         static const glw::GLenum  s_reference_internalformat;
6745         static const glw::GLenum  s_reference_format;
6746         static const glw::GLenum  s_reference_type;
6747 };
6748 /* GenerateMipmapErrorsTest class */
6749
6750 /** @class BindUnitErrorsTest
6751  *
6752  *      Check that INVALID_OPERATION error is generated if texture is not zero
6753  *      or the name of an existing texture object.
6754  */
6755 class BindUnitErrorsTest : public deqp::TestCase, ErrorsUtilities
6756 {
6757 public:
6758         /* Public member functions. */
6759         BindUnitErrorsTest(deqp::Context& context);
6760
6761         virtual tcu::TestNode::IterateResult iterate();
6762
6763 private:
6764         /* Private constructors. */
6765         BindUnitErrorsTest(const BindUnitErrorsTest& other);
6766         BindUnitErrorsTest& operator=(const BindUnitErrorsTest& other);
6767 };
6768 /* BindUnitErrorsTest class */
6769
6770 /** @class ImageQueryErrorsTest
6771  *
6772  *      Check that INVALID_OPERATION is generated by GetTextureImage if texture
6773  *      is not the name of an existing texture object.
6774  *
6775  *      Check that INVALID_ENUM is generated by GetTextureImage functions if
6776  *      resulting texture target is not an accepted value TEXTURE_1D,
6777  *      TEXTURE_2D, TEXTURE_3D, TEXTURE_1D_ARRAY, TEXTURE_2D_ARRAY,
6778  *      TEXTURE_CUBE_MAP_ARRAY, TEXTURE_RECTANGLE, and TEXTURE_CUBE_MAP.
6779  *
6780  *      Check that INVALID_OPERATION error is generated by GetTextureImage if
6781  *      the effective target is TEXTURE_CUBE_MAP or TEXTURE_CUBE_MAP_ARRAY, and
6782  *      the texture object is not cube complete or cube array complete,
6783  *      respectively.
6784  *
6785  *      Check that GL_INVALID_VALUE is generated if level is less than 0 or
6786  *      larger than the maximum allowable level.
6787  *
6788  *      Check that INVALID_VALUE error is generated if level is non-zero and the
6789  *      effective target is TEXTURE_RECTANGLE.
6790  *
6791  *      Check that INVALID_OPERATION error is generated if any of the following
6792  *      mismatches between format and the internal format of the texture image
6793  *      exist:
6794  *       -  format is a color format (one of the formats in table 8.3 whose
6795  *          target is the color buffer) and the base internal format of the
6796  *          texture image is not a color format.
6797  *       -  format is DEPTH_COMPONENT and the base internal format is  not
6798  *          DEPTH_COMPONENT or DEPTH_STENCIL
6799  *       -  format is DEPTH_STENCIL and the base internal format is not
6800  *          DEPTH_STENCIL
6801  *       -  format is STENCIL_INDEX and the base internal format is not
6802  *          STENCIL_INDEX or DEPTH_STENCIL
6803  *       -  format is one of the integer formats in table 8.3 and the internal
6804  *          format of the texture image is not integer, or format is not one of
6805  *          the integer formats in table 8.3 and the internal format is integer.
6806  *
6807  *      Check that INVALID_OPERATION error is generated if a pixel pack buffer
6808  *      object is bound and packing the texture image into the buffer’s memory
6809  *      would exceed the size of the buffer.
6810  *
6811  *      Check that INVALID_OPERATION error is generated if a pixel pack buffer
6812  *      object is bound and pixels is not evenly divisible by the number of
6813  *      basic machine units needed to store in memory the GL data type
6814  *      corresponding to type (see table 8.2).
6815  *
6816  *      Check that INVALID_OPERATION error is generated by GetTextureImage if
6817  *      the buffer size required to store the requested data is greater than
6818  *      bufSize.
6819  *
6820  *
6821  *      Check that INVALID_OPERATION is generated by GetCompressedTextureImage
6822  *      if texture is not the name of an existing texture object.
6823  *
6824  *      Check that INVALID_VALUE is generated by GetCompressedTextureImage if
6825  *      level is less than zero or greater than the maximum number of LODs
6826  *      permitted by the implementation.
6827  *
6828  *      Check that INVALID_OPERATION is generated if GetCompressedTextureImage
6829  *      is used to retrieve a texture that is in an uncompressed internal
6830  *      format.
6831  *
6832  *      Check that INVALID_OPERATION is generated by GetCompressedTextureImage
6833  *      if a non-zero buffer object name is bound to the PIXEL_PACK_BUFFER
6834  *      target, the buffer storage was not initialized with BufferStorage using
6835  *      MAP_PERSISTENT_BIT flag, and the buffer object's data store is currently
6836  *      mapped.
6837  *
6838  *      Check that INVALID_OPERATION is generated by GetCompressedTextureImage
6839  *      if a non-zero buffer object name is bound to the PIXEL_PACK_BUFFER
6840  *      target and the data would be packed to the buffer object such that the
6841  *      memory writes required would exceed the data store size.
6842  */
6843 class ImageQueryErrorsTest : public deqp::TestCase, ErrorsUtilities
6844 {
6845 public:
6846         /* Public member functions. */
6847         ImageQueryErrorsTest(deqp::Context& context);
6848
6849         virtual tcu::TestNode::IterateResult iterate();
6850
6851 private:
6852         /* Private constructors. */
6853         ImageQueryErrorsTest(const ImageQueryErrorsTest& other);
6854         ImageQueryErrorsTest& operator=(const ImageQueryErrorsTest& other);
6855
6856         static const glw::GLuint s_reference_data[];
6857         static const glw::GLuint s_reference_width;
6858         static const glw::GLuint s_reference_height;
6859         static const glw::GLuint s_reference_size;
6860         static const glw::GLenum s_reference_internalformat;
6861         static const glw::GLenum s_reference_internalformat_int;
6862         static const glw::GLenum s_reference_internalformat_compressed;
6863         static const glw::GLenum s_reference_format;
6864         static const glw::GLenum s_reference_type;
6865 };
6866 /* ImageQueryErrorsTest class */
6867
6868 /** @class LevelParameterErrorsTest
6869  *
6870  *      Check that INVALID_OPERATION is generated by GetTextureLevelParameterfv
6871  *      and GetTextureLevelParameteriv functions if texture is not the name of
6872  *      an existing texture object.
6873  *
6874  *      Check that INVALID_VALUE is generated by GetTextureLevelParameter* if
6875  *      level is less than 0.
6876  *
6877  *      Check that INVALID_VALUE may be generated if level is greater than
6878  *      log2 max, where max is the returned value of MAX_TEXTURE_SIZE.
6879  *
6880  *      Check that INVALID_OPERATION is generated by GetTextureLevelParameter*
6881  *      if TEXTURE_COMPRESSED_IMAGE_SIZE is queried on texture images with an
6882  *      uncompressed internal format or on proxy targets.
6883  *
6884  *      Check that INVALID_ENUM error is generated by GetTextureLevelParameter*
6885  *      if pname is not one of supported constants.
6886  */
6887 class LevelParameterErrorsTest : public deqp::TestCase, ErrorsUtilities
6888 {
6889 public:
6890         /* Public member functions. */
6891         LevelParameterErrorsTest(deqp::Context& context);
6892
6893         virtual tcu::TestNode::IterateResult iterate();
6894
6895 private:
6896         /* Private constructors. */
6897         LevelParameterErrorsTest(const LevelParameterErrorsTest& other);
6898         LevelParameterErrorsTest& operator=(const LevelParameterErrorsTest& other);
6899 };
6900 /* LevelParameterErrorsTest class */
6901
6902 /** @class
6903  *      Check that INVALID_ENUM is generated by glGetTextureParameter* if pname
6904  *      is not an accepted value.
6905  *
6906  *      Check that INVALID_OPERATION is generated by glGetTextureParameter* if
6907  *      texture is not the name of an existing texture object.
6908  *
6909  *      Check that INVALID_ENUM error is generated if the effective target is
6910  *      not one of the supported texture targets (eg. TEXTURE_BUFFER).
6911  */
6912 class ParameterErrorsTest : public deqp::TestCase, ErrorsUtilities
6913 {
6914 public:
6915         /* Public member functions. */
6916         ParameterErrorsTest(deqp::Context& context);
6917
6918         virtual tcu::TestNode::IterateResult iterate();
6919
6920 private:
6921         /* Private constructors. */
6922         ParameterErrorsTest(const ParameterErrorsTest& other);
6923         ParameterErrorsTest& operator=(const ParameterErrorsTest& other);
6924 };
6925 /* ParameterErrorsTest class */
6926 } /* Textures namespace */
6927 } /* DirectStateAccess namespace */
6928 } /* gl4cts namespace */
6929
6930 #endif // _GL4CDIRECTSTATEACCESSTESTS_HPP