Test behaviour of color write enable with colorWriteMask
[platform/upstream/VK-GL-CTS.git] / external / openglcts / modules / common / glcPixelStorageModesTests.cpp
1 /*-------------------------------------------------------------------------
2 * OpenGL Conformance Test Suite
3 * -----------------------------
4 *
5 * Copyright (c) 2020 The Khronos Group Inc.
6 * Copyright (c) 2020 Intel Corporation
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 *      http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 */ /*!
21 * \file  glcPixelStorageModesTests.cpp
22 * \brief Conformance tests for usage of pixel storage modes.
23 */ /*-------------------------------------------------------------------*/
24
25 #include "stdlib.h"
26 #include "tcuRenderTarget.hpp"
27 #include "tcuSurface.hpp"
28 #include "tcuTextureUtil.hpp"
29 #include "tcuTestCase.hpp"
30 #include "tcuTestLog.hpp"
31 #include "tcuDefs.hpp"
32 #include "tcuFloat.hpp"
33 #include "tcuStringTemplate.hpp"
34 #include "gluRenderContext.hpp"
35 #include "gluShaderProgram.hpp"
36 #include "gluShaderUtil.hpp"
37 #include "gluContextInfo.hpp"
38 #include "gluObjectWrapper.hpp"
39 #include "gluCallLogWrapper.hpp"
40 #include "gluPixelTransfer.hpp"
41 #include "gluTexture.hpp"
42 #include "gluTextureUtil.hpp"
43 #include "gluDrawUtil.hpp"
44 #include "gluDefs.hpp"
45 #include "sglrGLContext.hpp"
46 #include "sglrContextWrapper.hpp"
47 #include "sglrContextUtil.hpp"
48 #include "glwFunctions.hpp"
49 #include "glwEnums.hpp"
50 #include "deStringUtil.hpp"
51 #include "deUniquePtr.hpp"
52 #include "glsTextureTestUtil.hpp"
53 #include "glcPixelStorageModesTests.hpp"
54
55 #include <algorithm>
56
57 namespace glcts
58 {
59
60 static const char* const vs_template_src =
61         "${GLSL_VERSION}\n"
62         "in highp vec4 pos;\n"
63         "out highp ${TEXCOORDS_TYPE} texcoords;\n"
64         "${LAYER}\n"
65         "void main (void)\n"
66         "{\n"
67         "        texcoords = ${TEXCOORDS};\n"
68         "        gl_Position = pos;\n"
69         "}\n";
70
71 static const char* const fs_template_src =
72         "${GLSL_VERSION}\n"
73         "precision highp float;\n"
74         "precision highp int;\n"
75         "out vec4 fragColour;\n"
76         "in ${TEXCOORDS_TYPE} texcoords;\n"
77         "uniform highp ${SAMPLER_TYPE} sampler;\n"
78         "uniform ${COL_TYPE} refcolour;\n"
79         "void main (void)\n"
80         "{\n"
81         "        ${COL_TYPE} colour = texelFetch(sampler, i${TEXCOORDS_TYPE}(texcoords), 0);\n"
82         "        if (${CONDITION})\n"
83         "                fragColour = vec4(0.0, 1.0, 0.0, 1.0);\n"
84         "        else\n"
85         "                fragColour = vec4(colour);\n"
86         "}\n";
87
88 double getEps(deUint32 internalFormat)
89 {
90         double eps = 0.0;
91         switch (internalFormat)
92         {
93         case GL_RGBA4:
94                 eps = 1.0 / (double)(1 << 4);
95                 break;
96         case GL_RGB565:
97         case GL_RGB5_A1:
98         case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
99                 eps = 1.0 / (double)(1 << 5);
100                 break;
101         case GL_R8:
102         case GL_R8_SNORM:
103         case GL_RG8:
104         case GL_RG8_SNORM:
105         case GL_RGB8:
106         case GL_SRGB8:
107         case GL_RGB8_SNORM:
108         case GL_RGBA8:
109         case GL_SRGB8_ALPHA8:
110         case GL_RGBA8_SNORM:
111                 eps = 1.0 / (double)(1 << 8);
112                 break;
113         case GL_RGB9_E5:
114                 eps = 1.0 / (double)(1 << 9);
115                 break;
116         case GL_R11F_G11F_B10F:
117         case GL_RGB10_A2:
118                 eps = 1.0 / (double)(1 << 10);
119                 break;
120         case GL_R16F:
121         case GL_RG16F:
122         case GL_RGB16F:
123         case GL_RGBA16F:
124         case GL_COMPRESSED_RGBA_ASTC_8x5_KHR:
125                 eps = 1.0 / (double)(1 << 16);
126                 break;
127         case GL_R32F:
128         case GL_RG32F:
129         case GL_RGB32F:
130         case GL_RGBA32F:
131                 eps = 1.0 / (double)(1 << 31);
132                 break;
133         default:
134                 TCU_FAIL("Invalid internal format");
135                 break;
136         }
137
138         return std::max(0.01, eps);
139 }
140
141 bool inrange(int x, int left, int right)
142 {
143         return (x >= left && x < right);
144 }
145
146 class TexImageUtils
147 {
148 public:
149         TexImageUtils(deUint32 internalFormat,
150                                   int cuboid_w, int cuboid_h, int cuboid_d,
151                                   int subcuboid_x0, int subcuboid_y0, int subcuboid_z0,
152                                   int subcuboid_w, int subcuboid_h, int subcuboid_d,
153                                   glu::GLSLVersion glsl_version);
154         ~TexImageUtils (void);
155 protected:
156         void writePixel(glw::GLubyte *p, glw::GLdouble col);
157         void writeChannel(glw::GLubyte *p, int channel, glw::GLdouble col);
158         template <typename T>
159         void writeToUnsignedChannel(glw::GLubyte *p, int channel, glw::GLdouble col);
160         template <typename T>
161         void writeToSignedChannel(glw::GLubyte *p, int channel, glw::GLdouble col);
162         void writeToFloatChannel(glw::GLubyte *p, int channel, glw::GLdouble col);
163         void writeToHalfFloatChannel(glw::GLubyte *p, int channel, glw::GLdouble col);
164         template <typename T,
165                                  unsigned int size_1, unsigned int size_2, unsigned int size_3,
166                                  unsigned int off_1, unsigned int off_2, unsigned int off_3>
167         void write3Channel(glw::GLubyte *p, int channel, glw::GLdouble col);
168         template <typename T,
169                                  unsigned int size_1, unsigned int size_2,
170                                  unsigned int size_3, unsigned int size_4,
171                                  unsigned int off_1, unsigned int off_2,
172                                  unsigned int off_3, unsigned int off_4>
173         void write4Channel(glw::GLubyte *p, int channel, glw::GLdouble col);
174         void write11F_11F_10F_Channel(glw::GLubyte *p, int channel, glw::GLdouble col);
175         void setRefcolour (glu::CallLogWrapper gl, glw::GLdouble col);
176         template <typename T>
177         void setUnsignedRefcolour(glu::CallLogWrapper gl, glw::GLdouble col);
178         template <typename T>
179         void setSignedRefcolour(glu::CallLogWrapper gl, glw::GLdouble col);
180         void setRGB10A2Refcolour (glu::CallLogWrapper gl, glw::GLdouble col);
181         bool verify(tcu::Surface dst, tcu::Surface *errMask);
182
183         glw::GLubyte *m_src_data;
184         deUint32 tex;
185         glu::ShaderProgram* prog;
186
187         deUint32 m_internalFormat;
188         deUint32 m_format;
189         deUint32 m_type;
190         int m_pixelsize;
191         int m_num_channels;
192         int m_cuboid_w;
193         int m_cuboid_h;
194         int m_cuboid_d;
195         int m_subcuboid_x0;
196         int m_subcuboid_y0;
197         int m_subcuboid_z0;
198         int m_subcuboid_w;
199         int m_subcuboid_h;
200         int m_subcuboid_d;
201
202         glu::GLSLVersion m_glsl_version;
203 };
204
205 TexImageUtils::TexImageUtils (deUint32 internalFormat,
206                                                           int cuboid_w,
207                                                           int cuboid_h,
208                                                           int cuboid_d,
209                                                           int subcuboid_x0,
210                                                           int subcuboid_y0,
211                                                           int subcuboid_z0,
212                                                           int subcuboid_w,
213                                                           int subcuboid_h,
214                                                           int subcuboid_d,
215                                                           glu::GLSLVersion glsl_version)
216         : m_src_data(0)
217         , tex(0)
218         , prog(0)
219         , m_internalFormat(internalFormat)
220         , m_format(glu::getTransferFormat(glu::mapGLInternalFormat(internalFormat)).format)
221         , m_type(glu::getTransferFormat(glu::mapGLInternalFormat(internalFormat)).dataType)
222         , m_pixelsize(tcu::getPixelSize(glu::mapGLInternalFormat(internalFormat)))
223         , m_num_channels(tcu::getNumUsedChannels(glu::mapGLInternalFormat(internalFormat).order))
224         , m_cuboid_w(cuboid_w)
225         , m_cuboid_h(cuboid_h)
226         , m_cuboid_d(cuboid_d)
227         , m_subcuboid_x0(subcuboid_x0)
228         , m_subcuboid_y0(subcuboid_y0)
229         , m_subcuboid_z0(subcuboid_z0)
230         , m_subcuboid_w(subcuboid_w)
231         , m_subcuboid_h(subcuboid_h)
232         , m_subcuboid_d(subcuboid_d)
233         , m_glsl_version(glsl_version)
234 {
235 }
236
237 TexImageUtils::~TexImageUtils (void)
238 {
239 }
240
241 void TexImageUtils::writePixel(glw::GLubyte *p, glw::GLdouble col)
242 {
243         for (int ch = 0; ch < m_num_channels; ch++)
244                 writeChannel(p, ch, (ch == 3) ? 1.0 : col);
245 }
246
247 void TexImageUtils::writeChannel(glw::GLubyte *p, int channel, glw::GLdouble col)
248 {
249         switch (m_type)
250         {
251         case GL_UNSIGNED_BYTE:
252                 writeToUnsignedChannel<glw::GLubyte>(p, channel, col);
253                 break;
254         case GL_BYTE:
255                 writeToSignedChannel<glw::GLbyte>(p, channel, col);
256                 break;
257         case GL_UNSIGNED_SHORT:
258                 writeToUnsignedChannel<glw::GLushort>(p, channel, col);
259                 break;
260         case GL_UNSIGNED_SHORT_5_6_5:
261                 write3Channel<glw::GLushort, 5, 6, 5, 11, 5, 0>(p, channel, col);
262                 break;
263         case GL_SHORT:
264                 writeToSignedChannel<glw::GLshort>(p, channel, col);
265                 break;
266         case GL_UNSIGNED_INT:
267                 writeToUnsignedChannel<glw::GLuint>(p, channel, col);
268                 break;
269         case GL_UNSIGNED_INT_2_10_10_10_REV:
270                 write4Channel<glw::GLuint, 2, 10, 10, 10, 30, 20, 10, 0>(p, 3 - channel, col);
271                 break;
272         case GL_UNSIGNED_INT_10F_11F_11F_REV:
273                 write11F_11F_10F_Channel(p, channel, col);
274                 break;
275         case GL_UNSIGNED_SHORT_4_4_4_4:
276                 write4Channel<glw::GLushort, 4, 4, 4, 4, 12, 8, 4, 0>(p, channel, col);
277                 break;
278         case GL_UNSIGNED_SHORT_5_5_5_1:
279                 write4Channel<glw::GLushort, 5, 5, 5, 1, 11, 6, 1, 0>(p, channel, col);
280                 break;
281         case GL_INT:
282                 writeToSignedChannel<glw::GLint>(p, channel, col);
283                 break;
284         case GL_HALF_FLOAT:
285                 writeToHalfFloatChannel(p, channel, col);
286                 break;
287         case GL_FLOAT:
288                 writeToFloatChannel(p, channel, col);
289                 break;
290         default:
291                 TCU_FAIL("Invalid type");
292                 break;
293         }
294 }
295
296 template <typename T>
297 void TexImageUtils::writeToUnsignedChannel(glw::GLubyte *p, int channel, glw::GLdouble col)
298 {
299         static const T max = -1;
300
301         const glw::GLdouble d_max = (glw::GLdouble)max;
302         const glw::GLdouble d_value = col * d_max;
303         const T t_value = (T)d_value;
304
305         T* ptr = (T*)p;
306
307         ptr[channel] = t_value;
308 }
309
310 template <typename T>
311 void TexImageUtils::writeToSignedChannel(glw::GLubyte *p, int channel, glw::GLdouble col)
312 {
313         static const T max = (T)((1u << (sizeof(T) * 8u - 1u)) - 1u);
314
315         const glw::GLdouble d_max = (glw::GLdouble)max;
316         const glw::GLdouble d_value = col * d_max;
317         const T t_value = (T)d_value;
318
319         T* ptr = (T*)p;
320
321         ptr[channel] = t_value;
322 }
323
324 void TexImageUtils::writeToFloatChannel(glw::GLubyte *p, int channel, glw::GLdouble col)
325 {
326         const glw::GLfloat t_value = (glw::GLfloat)col;
327
328         glw::GLfloat *ptr = (glw::GLfloat*)p;
329
330         ptr[channel] = t_value;
331 }
332
333 void TexImageUtils::writeToHalfFloatChannel(glw::GLubyte *p, int channel, glw::GLdouble col)
334 {
335         deUint16* ptr = (deUint16*)p;
336
337         tcu::Float16 val(col);
338
339         ptr[channel] = val.bits();
340 }
341
342 template <typename T,
343                          unsigned int size_1, unsigned int size_2, unsigned int size_3,
344                          unsigned int off_1, unsigned int off_2, unsigned int off_3>
345 void TexImageUtils::write3Channel(glw::GLubyte *p, int channel, glw::GLdouble col)
346 {
347         T mask = 0;
348         T max = 0;
349         T off = 0;
350         T* ptr = (T*)p;
351         T result = 0;
352
353         const T max_1 = (1 << size_1) - 1;
354         const T max_2 = (1 << size_2) - 1;
355         const T max_3 = (1 << size_3) - 1;
356
357         switch (channel)
358         {
359         case 0:
360                 mask = max_1;
361                 max  = max_1;
362                 off  = off_1;
363                 break;
364         case 1:
365                 mask = max_2;
366                 max  = max_2;
367                 off  = off_2;
368                 break;
369         case 2:
370                 mask = max_3;
371                 max  = max_3;
372                 off  = off_3;
373                 break;
374         default:
375                 TCU_FAIL("Invalid channel");
376                 break;
377         }
378
379         const glw::GLdouble d_max        = (glw::GLdouble)max;
380         const glw::GLdouble d_value  = col * d_max;
381         const T t_value = (T)d_value;
382
383         result = (T)((t_value & mask) << off);
384
385         *ptr |= result;
386 }
387
388 template <typename T,
389                          unsigned int size_1, unsigned int size_2,
390                          unsigned int size_3, unsigned int size_4,
391                          unsigned int off_1, unsigned int off_2,
392                          unsigned int off_3, unsigned int off_4>
393 void TexImageUtils::write4Channel(glw::GLubyte *p, int channel, glw::GLdouble col)
394 {
395         T mask   = 0;
396         T max    = 0;
397         T off    = 0;
398         T* ptr   = (T*)p;
399         T result = 0;
400
401         T max_1 = (1 << size_1) - 1;
402         T max_2 = (1 << size_2) - 1;
403         T max_3 = (1 << size_3) - 1;
404         T max_4 = (1 << size_4) - 1;
405
406         switch (channel)
407         {
408         case 0:
409                 mask = max_1;
410                 max  = max_1;
411                 off  = off_1;
412                 break;
413         case 1:
414                 mask = max_2;
415                 max  = max_2;
416                 off  = off_2;
417                 break;
418         case 2:
419                 mask = max_3;
420                 max  = max_3;
421                 off  = off_3;
422                 break;
423         case 3:
424                 mask = max_4;
425                 max  = max_4;
426                 off  = off_4;
427                 break;
428         default:
429                 TCU_FAIL("Invalid channel");
430                 break;
431         }
432
433         const glw::GLdouble d_max        = (glw::GLdouble)max;
434         const glw::GLdouble d_value  = col * d_max;
435         const T t_value = (T)d_value;
436
437         result = (T)((t_value & mask) << off);
438
439         *ptr |= result;
440 }
441
442 void TexImageUtils::write11F_11F_10F_Channel(glw::GLubyte *p, int channel, glw::GLdouble col)
443 {
444         deUint32* ptr = (deUint32*)p;
445
446         switch (channel)
447         {
448         case 0:
449         {
450                 tcu::Float<deUint32, 5, 6, 15, tcu::FLOAT_SUPPORT_DENORM> val(col);
451                 deUint32 bits = val.bits();
452
453                 *ptr |= bits;
454         }
455         break;
456         case 1:
457         {
458                 tcu::Float<deUint32, 5, 6, 15, tcu::FLOAT_SUPPORT_DENORM> val(col);
459                 deUint32 bits = val.bits();
460
461                 *ptr |= (bits << 11);
462         }
463         break;
464         case 2:
465         {
466                 tcu::Float<deUint32, 5, 5, 15, tcu::FLOAT_SUPPORT_DENORM> val(col);
467                 deUint32 bits = val.bits();
468
469                 *ptr |= (bits << 22);
470         }
471         break;
472         default:
473                 TCU_FAIL("Invalid channel");
474                 break;
475         }
476 }
477
478 void TexImageUtils::setRefcolour (glu::CallLogWrapper gl, glw::GLdouble col)
479 {
480         switch (m_format)
481         {
482         case GL_RED:
483         case GL_RG:
484         case GL_RGB:
485         case GL_RGBA:
486                 gl.glUniform4f(gl.glGetUniformLocation(prog->getProgram(), "refcolour"),
487                                            m_num_channels > 0 ? col : 0.0f,
488                                            m_num_channels > 1 ? col : 0.0f,
489                                            m_num_channels > 2 ? col : 0.0f,
490                                            1.0f);
491                 break;
492         default:
493                 switch (m_type)
494                 {
495                 case GL_UNSIGNED_BYTE:
496                         setUnsignedRefcolour<glw::GLubyte>(gl, col);
497                         break;
498                 case GL_BYTE:
499                         setSignedRefcolour<glw::GLubyte>(gl, col);
500                         break;
501                 case GL_UNSIGNED_SHORT:
502                 case GL_UNSIGNED_SHORT_5_6_5:
503                 case GL_UNSIGNED_SHORT_4_4_4_4:
504                 case GL_UNSIGNED_SHORT_5_5_5_1:
505                         setUnsignedRefcolour<glw::GLushort>(gl, col);
506                         break;
507                 case GL_SHORT:
508                         setSignedRefcolour<glw::GLushort>(gl, col);
509                         break;
510                 case GL_UNSIGNED_INT:
511                         setUnsignedRefcolour<glw::GLuint>(gl, col);
512                         break;
513                 case GL_UNSIGNED_INT_2_10_10_10_REV:
514                         setRGB10A2Refcolour(gl, col);
515                         break;
516                 case GL_INT:
517                         setSignedRefcolour<glw::GLuint>(gl, col);
518                         break;
519                 default:
520                         TCU_FAIL("Invalid type");
521                         break;
522                 }
523         }
524 }
525
526 template <typename T>
527 void TexImageUtils::setUnsignedRefcolour (glu::CallLogWrapper gl, glw::GLdouble col)
528 {
529         static const T max = -1;
530         const glw::GLdouble d_max   = (glw::GLdouble)max;
531         const glw::GLdouble d_value = d_max * col;
532         const T t_value = (T)d_value;
533
534         unsigned int refcol[4] =
535         {
536                 m_num_channels > 0 ? t_value : 0u,
537                 m_num_channels > 1 ? t_value : 0u,
538                 m_num_channels > 2 ? t_value : 0u,
539                 255u,
540         };
541
542         gl.glUniform4uiv(gl.glGetUniformLocation(prog->getProgram(), "refcolour"), 1,
543                                          refcol);
544 }
545
546 template <typename T>
547 void TexImageUtils::setSignedRefcolour (glu::CallLogWrapper gl, glw::GLdouble col)
548 {
549         static const T umax = -1;
550         static const T max  = umax >> 1;
551
552         const glw::GLdouble d_max   = (glw::GLdouble)max;
553         const glw::GLdouble d_value = d_max * col;
554         const T t_value = (T)d_value;
555
556         int refcol[4] =
557         {
558                 (m_num_channels > 0 ? (int)t_value : 0),
559                 (m_num_channels > 1 ? (int)t_value : 0),
560                 (m_num_channels > 2 ? (int)t_value : 0),
561                 255,
562         };
563
564         gl.glUniform4iv(gl.glGetUniformLocation(prog->getProgram(), "refcolour"), 1,
565                                         refcol);
566 }
567
568 void TexImageUtils::setRGB10A2Refcolour (glu::CallLogWrapper gl, glw::GLdouble col)
569 {
570         unsigned int max_channel_value = 1023u;
571
572         const glw::GLdouble d_max_channel_value = (glw::GLdouble)max_channel_value;
573         const glw::GLdouble d_value = (glw::GLdouble)d_max_channel_value * col;
574         unsigned int t_value = (unsigned int)d_value;
575
576         unsigned int refcol[4] =
577         {
578                 (m_num_channels > 0 ? t_value : 0u),
579                 (m_num_channels > 1 ? t_value : 0u),
580                 (m_num_channels > 2 ? t_value : 0u),
581                 255u,
582         };
583
584         gl.glUniform4uiv(gl.glGetUniformLocation(prog->getProgram(), "refcolour"), 1,
585                                          refcol);
586 }
587
588 bool TexImageUtils::verify(tcu::Surface dst, tcu::Surface *errMask)
589 {
590         *errMask = tcu::Surface (dst.getWidth(), dst.getHeight());
591         tcu::clear(errMask->getAccess(), tcu::Vec4(0.0f, 1.0f, 0.0f, 1.0f));
592         bool pass = true;
593
594         for (int y = 0; y < dst.getHeight(); y++)
595         {
596                 for (int x = 0; x < dst.getWidth(); x++)
597                 {
598                         if (dst.getPixel(x, y) != tcu::RGBA::green())
599                         {
600                                 pass = false;
601                                 errMask->setPixel(x, y, tcu::RGBA::red());
602                         }
603                 }
604         }
605
606         return pass;
607 }
608
609 class TexImage2DCase : public deqp::TestCase
610                                          , public sglr::ContextWrapper
611                                          , public TexImageUtils
612 {
613 public:
614         TexImage2DCase (deqp::Context& context, const char* name, const char* desc,
615                                         deUint32 internalFormat,
616                                         int rect_w, int rect_h,
617                                         int subrect_x0, int subrect_y0,
618                                         int subrect_w, int subrect_h,
619                                         glu::GLSLVersion glsl_version);
620         ~TexImage2DCase (void);
621         IterateResult iterate (void);
622 protected:
623         void generateSrcData();
624         void createTexture (void);
625         void createShader (void);
626         tcu::Surface renderToSurf (void);
627         void cleanup (void);
628 };
629
630 TexImage2DCase::TexImage2DCase (deqp::Context& context,
631                                                                 const char* name,
632                                                                 const char* desc,
633                                                                 deUint32 internalFormat,
634                                                                 int rect_w,
635                                                                 int rect_h,
636                                                                 int subrect_x0,
637                                                                 int subrect_y0,
638                                                                 int subrect_w,
639                                                                 int subrect_h,
640                                                                 glu::GLSLVersion glsl_version)
641         : TestCase(context, name, desc)
642         , TexImageUtils(internalFormat,
643                                         rect_w, rect_h, 1,
644                                         subrect_x0, subrect_y0, 0,
645                                         subrect_w, subrect_h, 1,
646                                         glsl_version)
647 {
648 }
649
650 TexImage2DCase::~TexImage2DCase(void)
651 {
652 }
653
654 TexImage2DCase::IterateResult TexImage2DCase::iterate(void)
655 {
656         glu::RenderContext& renderCtx = TestCase::m_context.getRenderContext();
657         tcu::TestLog& log = m_testCtx.getLog();
658         tcu::Surface dst, errMask;
659
660         bool pass = true;
661
662         sglr::GLContext gl_ctx (renderCtx,
663                                                         log,
664                                                         sglr::GLCONTEXT_LOG_CALLS,
665                                                         tcu::IVec4(0, 0, m_subcuboid_w, m_subcuboid_h));
666
667         setContext((sglr::Context*)&gl_ctx);
668
669         generateSrcData();
670         createTexture();
671         createShader();
672         dst = renderToSurf();
673
674         pass = verify(dst, &errMask);
675
676         cleanup();
677
678         if (pass)
679         {
680                 m_testCtx.getLog()
681                 << tcu::TestLog::Message << "Image is valid" << tcu::TestLog::EndMessage
682                 << tcu::TestLog::ImageSet("ImageVerification", "Image verification")
683                 << tcu::TestLog::Image("Result", "Rendered result", dst.getAccess())
684                 << tcu::TestLog::EndImageSet;
685         }
686         else
687         {
688                 m_testCtx.getLog()
689                 << tcu::TestLog::Message << "Image is invalid" << tcu::TestLog::EndMessage
690                 << tcu::TestLog::ImageSet("ErrorVerification", "Image verification")
691                 << tcu::TestLog::Image("Result", "Rendered result", dst.getAccess())
692                 << tcu::TestLog::Image("ErrorMask", "Error mask", errMask.getAccess())
693                 << tcu::TestLog::EndImageSet;
694         }
695
696         m_testCtx.setTestResult(pass ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
697                                                         pass ? "Pass" : "Fail");
698
699         return STOP;
700 }
701
702 void TexImage2DCase::generateSrcData()
703 {
704         m_src_data = new glw::GLubyte[m_cuboid_w * m_cuboid_h * m_pixelsize]();
705
706         glw::GLdouble col = 0.0;
707
708         for (int y = 0; y < m_cuboid_h; y++)
709         {
710                 for (int x = 0; x < m_cuboid_w; x++)
711                 {
712                         if (inrange(y, m_subcuboid_y0, m_subcuboid_y0 + m_subcuboid_h) &&
713                                 inrange(x, m_subcuboid_x0, m_subcuboid_x0 + m_subcuboid_w))
714                                 col = 1.0;
715                         else
716                                 col = 0.0;
717                         int offset = y * m_cuboid_w * m_pixelsize +
718                                                  x * m_pixelsize;
719                         writePixel(m_src_data + offset, col);
720                 }
721         }
722 }
723
724 void TexImage2DCase::createTexture (void)
725 {
726         glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(),
727                                                         m_testCtx.getLog());
728
729         gl.glGenTextures(1, &tex);
730         gl.glBindTexture(GL_TEXTURE_2D, tex);
731         gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
732         gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
733
734         gl.glPixelStorei(GL_UNPACK_ROW_LENGTH,  m_cuboid_w);
735         gl.glPixelStorei(GL_UNPACK_SKIP_ROWS,   m_subcuboid_y0);
736         gl.glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_subcuboid_x0);
737
738         gl.glTexImage2D(GL_TEXTURE_2D,
739                                         0,
740                                         m_internalFormat,
741                                         m_subcuboid_w,
742                                         m_subcuboid_h,
743                                         0,
744                                         m_format,
745                                         m_type,
746                                         m_src_data);
747
748         gl.glPixelStorei(GL_UNPACK_ROW_LENGTH,   0);
749         gl.glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
750         gl.glPixelStorei(GL_UNPACK_SKIP_ROWS,    0);
751 }
752
753 void TexImage2DCase::createShader (void)
754 {
755         glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(),
756                                                         m_testCtx.getLog());
757
758         const tcu::StringTemplate vs_src (vs_template_src);
759         const tcu::StringTemplate fs_src (fs_template_src);
760
761         std::map<std::string,std::string> params;
762         params["GLSL_VERSION"]   = getGLSLVersionDeclaration(m_glsl_version);
763         params["TEXCOORDS_TYPE"] = "vec2";
764         params["LAYER"]                  = "";
765         params["TEXCOORDS"]              = "pos.xy";
766         params["CONDITION"]              = "colour.rgb == refcolour.rgb";
767
768         switch (m_format)
769         {
770         case GL_RED_INTEGER:
771         case GL_RG_INTEGER:
772         case GL_RGB_INTEGER:
773         case GL_RGBA_INTEGER:
774                 switch (m_type)
775                 {
776                 case GL_BYTE:
777                 case GL_SHORT:
778                 case GL_INT:
779                         params["SAMPLER_TYPE"] = "isampler2D";
780                         params["COL_TYPE"]       = "ivec4";
781                         break;
782                 default:
783                         params["SAMPLER_TYPE"] = "usampler2D";
784                         params["COL_TYPE"]         = "uvec4";
785                         break;
786                 }
787                 break;
788         default:
789                 params["SAMPLER_TYPE"] = "sampler2D";
790                 params["COL_TYPE"]         = "vec4";
791                 break;
792         }
793
794         prog = new glu::ShaderProgram(m_context.getRenderContext(),
795                                                                   glu::ProgramSources() <<
796                                                                   glu::VertexSource(vs_src.specialize(params)) <<
797                                                                   glu::FragmentSource(fs_src.specialize(params)));
798
799         if (!prog->isOk())
800         {
801                 m_testCtx.getLog()
802                         << tcu::TestLog::Message << ""
803                         << tcu::TestLog::EndMessage
804                         << tcu::TestLog::ShaderProgram(false, "")
805                         << tcu::TestLog::Shader(QP_SHADER_TYPE_VERTEX,
806                                                                         prog->getShaderInfo(glu::SHADERTYPE_VERTEX,
807                                                                                                                 0).source,
808                                                                         false,
809                                                                         prog->getShaderInfo(glu::SHADERTYPE_VERTEX,
810                                                                                                                 0).infoLog)
811
812                         << tcu::TestLog::Shader(QP_SHADER_TYPE_FRAGMENT,
813                                                                         prog->getShaderInfo(glu::SHADERTYPE_FRAGMENT,
814                                                                                                                 0).source,
815                                                                         false,
816                                                                         prog->getShaderInfo(glu::SHADERTYPE_FRAGMENT,
817                                                                                                                 0).infoLog)
818                         << tcu::TestLog::EndShaderProgram;
819                 TCU_FAIL("Shader creation failed");
820         }
821
822         gl.glUseProgram(prog->getProgram());
823         gl.glUniform1i(gl.glGetUniformLocation(prog->getProgram(), "sampler"), 0);
824 }
825
826 tcu::Surface TexImage2DCase::renderToSurf (void)
827 {
828         glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(),
829                                                         m_testCtx.getLog());
830         gl.glClearColor(0.3f, 0.3f, 0.3f, 1.0f);
831         gl.glClear(GL_COLOR_BUFFER_BIT);
832
833         static const float vertexPositions[4*3] =
834         {
835                 -1.0, -1.0, -1.0f,
836                  1.0, -1.0,  0.0f,
837                 -1.0,  1.0,  0.0f,
838                  1.0,  1.0,  1.0f,
839         };
840
841         static const deUint16 indices[6] = { 0, 1, 2, 2, 1, 3 };
842
843         const glu::VertexArrayBinding attrBindings[] =
844         {
845                 glu::va::Float("pos", 3, 4, 0, &vertexPositions[0])
846         };
847
848         gl.glViewport(0, 0, m_subcuboid_w, m_subcuboid_h);
849         setRefcolour(gl, 1.0);
850         glu::draw(m_context.getRenderContext(),
851                           prog->getProgram(),
852                           DE_LENGTH_OF_ARRAY(attrBindings),
853                           &attrBindings[0],
854                           glu::pr::Triangles(DE_LENGTH_OF_ARRAY(indices), &indices[0]));
855
856         tcu::Surface dst;
857         dst.setSize(m_subcuboid_w, m_subcuboid_h);
858
859         glu::readPixels(m_context.getRenderContext(), 0, 0, dst.getAccess());
860
861         return dst;
862 }
863
864 void TexImage2DCase::cleanup (void)
865 {
866         glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(),
867                                                         m_testCtx.getLog());
868
869         gl.glDeleteTextures(1, &tex);
870         delete[] m_src_data;
871         delete prog;
872 }
873
874 class TexImage3DCase : public deqp::TestCase
875                                          , public sglr::ContextWrapper
876                                          , public TexImageUtils
877 {
878 public:
879         TexImage3DCase (deqp::Context& context, const char* name, const char* desc,
880                                         deUint32 internalFormat,
881                                         int cuboid_w, int cuboid_h, int cuboid_d,
882                                         int subcuboid_x0, int subrect_y0, int subcuboid_z0,
883                                         int subcuboid_w, int subcuboid_h, int subcuboid_d,
884                                         glu::GLSLVersion glsl_version);
885         ~TexImage3DCase (void);
886         IterateResult iterate (void);
887 protected:
888         void generateSrcData();
889         void createTexture (void);
890         void createShader (void);
891         tcu::Surface renderToSurf (int layer);
892         void cleanup (void);
893 };
894
895 TexImage3DCase::TexImage3DCase (deqp::Context& context,
896                                                                 const char* name,
897                                                                 const char* desc,
898                                                                 deUint32 internalFormat,
899                                                                 int cuboid_w,
900                                                                 int cuboid_h,
901                                                                 int cuboid_d,
902                                                                 int subcuboid_x0,
903                                                                 int subcuboid_y0,
904                                                                 int subcuboid_z0,
905                                                                 int subcuboid_w,
906                                                                 int subcuboid_h,
907                                                                 int subcuboid_d,
908                                                                 glu::GLSLVersion glsl_version)
909         : TestCase(context, name, desc)
910         , TexImageUtils(internalFormat,
911                                         cuboid_w, cuboid_h, cuboid_d,
912                                         subcuboid_x0, subcuboid_y0, subcuboid_z0,
913                                         subcuboid_w, subcuboid_h, subcuboid_d,
914                                         glsl_version)
915 {
916 }
917
918 TexImage3DCase::~TexImage3DCase(void)
919 {
920 }
921
922 TexImage3DCase::IterateResult TexImage3DCase::iterate(void)
923 {
924         glu::RenderContext& renderCtx = TestCase::m_context.getRenderContext();
925         tcu::TestLog& log = m_testCtx.getLog();
926         tcu::Surface dst, errMask;
927
928         bool pass = true;
929
930         sglr::GLContext gl_ctx (renderCtx,
931                                                         log,
932                                                         sglr::GLCONTEXT_LOG_CALLS,
933                                                         tcu::IVec4(0, 0, m_subcuboid_w, m_subcuboid_h));
934
935         setContext((sglr::Context*)&gl_ctx);
936
937         generateSrcData();
938         createTexture();
939         createShader();
940
941         for (int z = 0; z < m_subcuboid_d; z++)
942         {
943                 dst = renderToSurf(z);
944
945                 bool layer_pass = verify(dst, &errMask);
946
947                 if (layer_pass)
948                 {
949                         m_testCtx.getLog()
950                                 << tcu::TestLog::Message << "Layer " << z        << " is valid"
951                                 << tcu::TestLog::EndMessage
952                                 << tcu::TestLog::ImageSet("LayerVerification", "Layer verification")
953                                 << tcu::TestLog::Image("Result", "Rendered result", dst.getAccess())
954                                 << tcu::TestLog::EndImageSet;
955                 }
956                 else
957                 {
958                         m_testCtx.getLog()
959                                 << tcu::TestLog::Message << "Layer " << z << " is invalid"
960                                 << tcu::TestLog::EndMessage
961                                 << tcu::TestLog::ImageSet("ErrorVerification", "Layer verification")
962                                 << tcu::TestLog::Image("Result", "Rendered result", dst.getAccess())
963                                 << tcu::TestLog::Image("ErrorMask", "Error mask", errMask.getAccess())
964                                 << tcu::TestLog::EndImageSet;
965                 }
966
967                 pass &= layer_pass;
968         }
969
970         cleanup();
971
972         if (pass)
973         {
974                 m_testCtx.getLog()
975                         << tcu::TestLog::Message << "Image is valid" << tcu::TestLog::EndMessage;
976         }
977         else
978         {
979                 m_testCtx.getLog()
980                         << tcu::TestLog::Message << "Image is invalid" << tcu::TestLog::EndMessage;
981         }
982
983         m_testCtx.setTestResult(pass ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
984                                                                         pass ? "Pass" : "Fail");
985
986         return STOP;
987 }
988
989 void TexImage3DCase::generateSrcData()
990 {
991         m_src_data = new glw::GLubyte[m_cuboid_w *
992                                                                   m_cuboid_h *
993                                                                   m_cuboid_d *
994                                                                   m_pixelsize]();
995
996         glw::GLdouble col = 0.0;
997
998         for (int z = 0; z < m_cuboid_d; z++)
999         {
1000                 for (int y = 0; y < m_cuboid_h; y++)
1001                 {
1002                         for (int x = 0; x < m_cuboid_w; x++)
1003                         {
1004                                 if (inrange(z, m_subcuboid_z0, m_subcuboid_z0 + m_subcuboid_d) &&
1005                                         inrange(y, m_subcuboid_y0, m_subcuboid_y0 + m_subcuboid_h) &&
1006                                         inrange(x, m_subcuboid_x0, m_subcuboid_x0 + m_subcuboid_w))
1007                                         col = 0.125 + (z - m_subcuboid_z0) * 0.125; /* [0.125, 0.250..1.0] */
1008                                 else
1009                                         col = 0.0;
1010                                 int offset = z * m_cuboid_h * m_cuboid_w * m_pixelsize +
1011                                                          y * m_cuboid_w * m_pixelsize +
1012                                                          x * m_pixelsize;
1013                                 writePixel(m_src_data + offset, col);
1014                         }
1015                 }
1016         }
1017 }
1018
1019 void TexImage3DCase::createTexture (void)
1020 {
1021         glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(),
1022                                                         m_testCtx.getLog());
1023
1024         gl.glGenTextures(1, &tex);
1025         gl.glBindTexture(GL_TEXTURE_2D_ARRAY, tex);
1026         gl.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1027         gl.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1028
1029         gl.glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, m_cuboid_h);
1030         gl.glPixelStorei(GL_UNPACK_ROW_LENGTH,   m_cuboid_w);
1031         gl.glPixelStorei(GL_UNPACK_SKIP_IMAGES,  m_subcuboid_z0);
1032         gl.glPixelStorei(GL_UNPACK_SKIP_ROWS,    m_subcuboid_y0);
1033         gl.glPixelStorei(GL_UNPACK_SKIP_PIXELS,  m_subcuboid_x0);
1034
1035         gl.glTexImage3D(GL_TEXTURE_2D_ARRAY,
1036                                         0,
1037                                         m_internalFormat,
1038                                         m_subcuboid_w,
1039                                         m_subcuboid_h,
1040                                         m_subcuboid_d,
1041                                         0,
1042                                         m_format,
1043                                         m_type,
1044                                         m_src_data);
1045
1046         gl.glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, 0);
1047         gl.glPixelStorei(GL_UNPACK_ROW_LENGTH,   0);
1048         gl.glPixelStorei(GL_UNPACK_SKIP_IMAGES,  0);
1049         gl.glPixelStorei(GL_UNPACK_SKIP_ROWS,    0);
1050         gl.glPixelStorei(GL_UNPACK_SKIP_PIXELS,  0);
1051 }
1052
1053 void TexImage3DCase::createShader (void)
1054 {
1055         glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(),
1056                                                         m_testCtx.getLog());
1057
1058         const tcu::StringTemplate vs_src (vs_template_src);
1059         const tcu::StringTemplate fs_src (fs_template_src);
1060
1061         std::map<std::string,std::string> params;
1062         params["GLSL_VERSION"]   = getGLSLVersionDeclaration(m_glsl_version);
1063         params["TEXCOORDS_TYPE"] = "vec3";
1064         params["LAYER"]                  = "uniform int layer;";
1065         params["TEXCOORDS"]              = "vec3(pos.xy, layer)";
1066
1067         switch (m_format)
1068         {
1069         case GL_RED_INTEGER:
1070         case GL_RG_INTEGER:
1071         case GL_RGB_INTEGER:
1072         case GL_RGBA_INTEGER:
1073                 switch (m_type)
1074                 {
1075                 case GL_BYTE:
1076                 case GL_SHORT:
1077                 case GL_INT:
1078                         params["SAMPLER_TYPE"] = "isampler2DArray";
1079                         params["COL_TYPE"]       = "ivec4";
1080                         params["CONDITION"]      = "all(lessThan(uvec4(abs(colour - refcolour)).rgb, uvec3(2u)))";
1081                         break;
1082                 default:
1083                         params["SAMPLER_TYPE"] = "usampler2DArray";
1084                         params["COL_TYPE"]         = "uvec4";
1085                         params["CONDITION"]        = "all(lessThan(uvec4(abs(ivec4(colour) - ivec4(refcolour))).rgb, uvec3(2u)))";
1086                         break;
1087                 }
1088                 break;
1089         default:
1090                 const tcu::StringTemplate fs_condition ("all(lessThan((abs(colour - refcolour)).rgb, vec3(${EPS})))");
1091                 std::map<std::string, std::string> fs_condition_params;
1092                 fs_condition_params["EPS"] = std::to_string(getEps(m_internalFormat));
1093                 params["SAMPLER_TYPE"] = "sampler2DArray";
1094                 params["COL_TYPE"]        = "vec4";
1095                 params["CONDITION"]       = fs_condition.specialize(fs_condition_params);
1096                 break;
1097         }
1098
1099         prog = new glu::ShaderProgram(m_context.getRenderContext(),
1100                                                                   glu::ProgramSources() <<
1101                                                                   glu::VertexSource(vs_src.specialize(params)) <<
1102                                                                   glu::FragmentSource(fs_src.specialize(params)));
1103
1104         if (!prog->isOk())
1105         {
1106                 m_testCtx.getLog()
1107                         << tcu::TestLog::Message << ""
1108                         << tcu::TestLog::EndMessage
1109                         << tcu::TestLog::ShaderProgram(false, "")
1110                         << tcu::TestLog::Shader(QP_SHADER_TYPE_VERTEX,
1111                                                                         prog->getShaderInfo(glu::SHADERTYPE_VERTEX,
1112                                                                                                                 0).source,
1113                                                                         false,
1114                                                                         prog->getShaderInfo(glu::SHADERTYPE_VERTEX,
1115                                                                                                                 0).infoLog)
1116
1117                         << tcu::TestLog::Shader(QP_SHADER_TYPE_FRAGMENT,
1118                                                                         prog->getShaderInfo(glu::SHADERTYPE_FRAGMENT,
1119                                                                                                                 0).source,
1120                                                                         false,
1121                                                                         prog->getShaderInfo(glu::SHADERTYPE_FRAGMENT,
1122                                                                                                                 0).infoLog)
1123                         << tcu::TestLog::EndShaderProgram;
1124                 TCU_FAIL("Shader creation failed");
1125         }
1126
1127         gl.glUseProgram(prog->getProgram());
1128         gl.glUniform1i(gl.glGetUniformLocation(prog->getProgram(), "sampler"), 0);
1129 }
1130
1131 tcu::Surface TexImage3DCase::renderToSurf (int layer)
1132 {
1133         glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(),
1134                                                         m_testCtx.getLog());
1135         gl.glClearColor(0.3f, 0.3f, 0.3f, 1.0f);
1136         gl.glClear(GL_COLOR_BUFFER_BIT);
1137
1138         static const float vertexPositions[4*3] =
1139         {
1140                 -1.0, -1.0, -1.0f,
1141                  1.0, -1.0,      0.0f,
1142                 -1.0,  1.0,      0.0f,
1143                 1.0,   1.0,      1.0f,
1144         };
1145
1146         static const deUint16 indices[6] = { 0, 1, 2, 2, 1, 3 };
1147
1148         const glu::VertexArrayBinding attrBindings[] =
1149         {
1150                 glu::va::Float("pos", 3, 4, 0, &vertexPositions[0])
1151         };
1152
1153         gl.glViewport(0, 0, m_subcuboid_w, m_subcuboid_h);
1154
1155         gl.glUniform1i(gl.glGetUniformLocation(prog->getProgram(), "layer"), layer);
1156         glw::GLfloat refcol = 0.125 + layer * 0.125;
1157         setRefcolour(gl, refcol);
1158         glu::draw(m_context.getRenderContext(),
1159                           prog->getProgram(),
1160                           DE_LENGTH_OF_ARRAY(attrBindings),
1161                           &attrBindings[0],
1162                           glu::pr::Triangles(DE_LENGTH_OF_ARRAY(indices), &indices[0]));
1163
1164         tcu::Surface dst;
1165         dst.setSize(m_subcuboid_w, m_subcuboid_h);
1166
1167         glu::readPixels(m_context.getRenderContext(), 0, 0, dst.getAccess());
1168
1169         return dst;
1170 }
1171
1172 void TexImage3DCase::cleanup (void)
1173 {
1174         glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(),
1175                                                         m_testCtx.getLog());
1176
1177         gl.glDeleteTextures(1, &tex);
1178         delete[] m_src_data;
1179         delete prog;
1180 }
1181
1182 class CompressedTexImageUtils
1183 {
1184 public:
1185         CompressedTexImageUtils (deUint32 internalFormat,
1186                                                          int cuboid_w, int cuboid_h, int cuboid_d,
1187                                                          int subcuboid_x0, int subcuboid_y0, int subcuboid_z0,
1188                                                          int subcuboid_w, int subcuboid_h, int subcuboid_d,
1189                                                          glu::GLSLVersion glsl_version);
1190         ~CompressedTexImageUtils (void);
1191 protected:
1192         int getImageSize (int width, int height, int depth);
1193         bool verify(tcu::Surface dst, tcu::Surface *errMask);
1194
1195         glw::GLubyte *m_src_data;
1196         deUint32 tex;
1197         glu::ShaderProgram *prog;
1198
1199         int m_bw;                                       /* block width */
1200         int m_bh;                                       /* block height */
1201         int m_bd;                                       /* block depth */
1202         int m_bs;                                       /* block size */
1203
1204         deUint32 m_internalFormat;
1205         int m_cuboid_w;
1206         int m_cuboid_h;
1207         int m_cuboid_d;
1208         int m_subcuboid_x0;
1209         int m_subcuboid_y0;
1210         int m_subcuboid_z0;
1211         int m_subcuboid_w;
1212         int m_subcuboid_h;
1213         int m_subcuboid_d;
1214
1215         glu::GLSLVersion m_glsl_version;
1216 };
1217
1218 CompressedTexImageUtils::CompressedTexImageUtils (deUint32 internalFormat,
1219                                                                                                   int cuboid_w,
1220                                                                                                   int cuboid_h,
1221                                                                                                   int cuboid_d,
1222                                                                                                   int subcuboid_x0,
1223                                                                                                   int subcuboid_y0,
1224                                                                                                   int subcuboid_z0,
1225                                                                                                   int subcuboid_w,
1226                                                                                                   int subcuboid_h,
1227                                                                                                   int subcuboid_d,
1228                                                                                                   glu::GLSLVersion glsl_version)
1229         : m_internalFormat(internalFormat)
1230         , m_cuboid_w(cuboid_w)
1231         , m_cuboid_h(cuboid_h)
1232         , m_cuboid_d(cuboid_d)
1233         , m_subcuboid_x0(subcuboid_x0)
1234         , m_subcuboid_y0(subcuboid_y0)
1235         , m_subcuboid_z0(subcuboid_z0)
1236         , m_subcuboid_w(subcuboid_w)
1237         , m_subcuboid_h(subcuboid_h)
1238         , m_subcuboid_d(subcuboid_d)
1239         , m_glsl_version(glsl_version)
1240 {
1241 }
1242
1243 CompressedTexImageUtils::~CompressedTexImageUtils(void)
1244 {
1245 }
1246
1247 int CompressedTexImageUtils::getImageSize (int width, int height, int depth)
1248 {
1249         return (width / m_bw + (width % m_bw > 0)) *
1250                    (height / m_bh + (height % m_bh > 0)) *
1251                    (depth / m_bd + (depth % m_bd > 0)) *
1252                    m_bs;
1253 }
1254
1255 bool CompressedTexImageUtils::verify(tcu::Surface dst, tcu::Surface *errMask)
1256 {
1257         *errMask = tcu::Surface (dst.getWidth(), dst.getHeight());
1258         tcu::clear(errMask->getAccess(), tcu::Vec4(0.0f, 1.0f, 0.0f, 1.0f));
1259         bool pass = true;
1260
1261         for (int y = 0; y < dst.getHeight(); y++)
1262         {
1263                 for (int x = 0; x < dst.getWidth(); x++)
1264                 {
1265                         if (dst.getPixel(x, y) != tcu::RGBA::green())
1266                         {
1267                                 pass = false;
1268                                 errMask->setPixel(x, y, tcu::RGBA::red());
1269                         }
1270                 }
1271         }
1272
1273         return pass;
1274 }
1275
1276 class CompressedTexImage2DCase : public deqp::TestCase
1277                                                            , public sglr::ContextWrapper
1278                                                            , public CompressedTexImageUtils
1279 {
1280 public:
1281         CompressedTexImage2DCase (deqp::Context& context, const char *name, const char *desc,
1282                                                           deUint32 internalFormat,
1283                                                           int cuboid_w, int cuboid_h,
1284                                                           int subcuboid_x0, int subcuboid_y0,
1285                                                           int subcuboid_w, int subcuboid_h,
1286                                                           glu::GLSLVersion glsl_version);
1287         ~CompressedTexImage2DCase (void);
1288         IterateResult iterate (void);
1289 protected:
1290         void generateSrcData_s3tc (void);
1291         void generateSrcData_astc (void);
1292         void createTexture (void);
1293         void createShader (void);
1294         tcu::Surface renderToSurf (void);
1295         void cleanup (void);
1296 };
1297
1298 CompressedTexImage2DCase::CompressedTexImage2DCase (deqp::Context& context,
1299                                                                                                         const char *name,
1300                                                                                                         const char *desc,
1301                                                                                                         deUint32 internalFormat,
1302                                                                                                         int cuboid_w,
1303                                                                                                         int cuboid_h,
1304                                                                                                         int subcuboid_x0,
1305                                                                                                         int subcuboid_y0,
1306                                                                                                         int subcuboid_w,
1307                                                                                                         int subcuboid_h,
1308                                                                                                         glu::GLSLVersion glsl_version)
1309         : TestCase(context, name, desc)
1310         , CompressedTexImageUtils(internalFormat,
1311                                                           cuboid_w,
1312                                                           cuboid_h,
1313                                                           1,
1314                                                           subcuboid_x0,
1315                                                           subcuboid_y0,
1316                                                           0,
1317                                                           subcuboid_w,
1318                                                           subcuboid_h,
1319                                                           1,
1320                                                           glsl_version)
1321 {
1322 }
1323
1324 CompressedTexImage2DCase::~CompressedTexImage2DCase (void)
1325 {
1326 }
1327
1328 CompressedTexImage2DCase::IterateResult CompressedTexImage2DCase::iterate (void)
1329 {
1330         glu::RenderContext& renderCtx = TestCase::m_context.getRenderContext();
1331         const glu::ContextInfo& ctxInfo = m_context.getContextInfo();
1332         tcu::TestLog& log = m_testCtx.getLog();
1333         tcu::Surface dst, errMask;
1334
1335         bool pass = true;
1336
1337         sglr::GLContext gl_ctx (renderCtx,
1338                                                         log,
1339                                                         sglr::GLCONTEXT_LOG_CALLS,
1340                                                         tcu::IVec4(0, 0, m_subcuboid_w, m_subcuboid_h));
1341
1342         setContext((sglr::Context*)&gl_ctx);
1343
1344         switch (m_internalFormat)
1345         {
1346         case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
1347                 if (!ctxInfo.isExtensionSupported("GL_EXT_texture_compression_s3tc"))
1348                 {
1349                         m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED,
1350                                                                         "GL_EXT_texture_compression_s3tc extension is not supported");
1351                         return STOP;
1352                 }
1353
1354                 m_bw = 4;
1355                 m_bh = 4;
1356                 m_bd = 1;
1357                 m_bs = 8;
1358
1359                 generateSrcData_s3tc();
1360                 break;
1361         case GL_COMPRESSED_RGBA_ASTC_8x5_KHR:
1362                 if (!ctxInfo.isExtensionSupported("GL_KHR_texture_compression_astc_ldr"))
1363                 {
1364                         m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED,
1365                                                                         "GL_KHR_texture_compression_astc_ldr extension is not supported");
1366                         return STOP;
1367                 }
1368                 m_bw = 8;
1369                 m_bh = 5;
1370                 m_bd = 1;
1371                 m_bs = 16;
1372
1373                 generateSrcData_astc();
1374                 break;
1375         default:
1376                 TCU_FAIL("Invalid internal format");
1377                 break;
1378         }
1379
1380         createTexture();
1381         createShader();
1382
1383         dst = renderToSurf();
1384         pass = verify(dst, &errMask);
1385
1386         cleanup();
1387
1388         if (pass)
1389         {
1390                 m_testCtx.getLog()
1391                 << tcu::TestLog::Message << "Image is valid" << tcu::TestLog::EndMessage
1392                 << tcu::TestLog::ImageSet("ImageVerification", "Image verification")
1393                 << tcu::TestLog::Image("Result", "Rendered result", dst.getAccess())
1394                 << tcu::TestLog::EndImageSet;
1395         }
1396         else
1397         {
1398                 m_testCtx.getLog()
1399                 << tcu::TestLog::Message << "Image is invalid" << tcu::TestLog::EndMessage
1400                 << tcu::TestLog::ImageSet("ErrorVerification", "Image verification")
1401                 << tcu::TestLog::Image("Result", "Rendered result", dst.getAccess())
1402                 << tcu::TestLog::Image("ErrorMask", "Error mask", errMask.getAccess())
1403                 << tcu::TestLog::EndImageSet;
1404         }
1405
1406         m_testCtx.setTestResult(pass ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
1407                                                         pass ? "Pass" : "Fail");
1408
1409         return STOP;
1410 }
1411
1412 void CompressedTexImage2DCase::generateSrcData_s3tc (void)
1413 {
1414         deUint64 *src = new deUint64[m_cuboid_w / m_bw * m_cuboid_h / m_bh];
1415
1416         deUint64 col = 0x0;
1417
1418         for (int y = 0; y < m_cuboid_h; y += m_bh)
1419         {
1420                 for (int x = 0; x < m_cuboid_w; x += m_bw)
1421                 {
1422                         if (inrange(x, m_subcuboid_x0, m_subcuboid_x0 + m_subcuboid_w) &&
1423                                 inrange(y, m_subcuboid_y0, m_subcuboid_y0 + m_subcuboid_h))
1424                         {
1425                                 col = 0xffff;
1426                         }
1427                         else
1428                         {
1429                                 col = 0x0;
1430                         }
1431                         int index = (y / m_bh) * (m_cuboid_w / m_bw) +
1432                                                         (x / m_bw);
1433                         src[index] = col;
1434                 }
1435         }
1436
1437         m_src_data = (glw::GLubyte*)src;
1438 }
1439
1440 void CompressedTexImage2DCase::generateSrcData_astc (void)
1441 {
1442         deUint64 col = 0x0;
1443         deUint64 mask = 0xfffffffffffffdfc;
1444
1445         int img_size = 2 * (m_cuboid_w / m_bw + (m_cuboid_w % m_bw > 0)) *
1446                                    (m_cuboid_h / m_bh + (m_cuboid_h % m_bh > 0));
1447
1448         deUint64 *src = new deUint64[img_size];
1449
1450         for (int y = 0; y < m_cuboid_h; y += m_bh)
1451         {
1452                 for (int x = 0; x < m_cuboid_w; x += m_bw)
1453                 {
1454                         if (inrange(x, m_subcuboid_x0, m_subcuboid_x0 + m_subcuboid_w) &&
1455                                 inrange(y, m_subcuboid_y0, m_subcuboid_y0 + m_subcuboid_h))
1456                         {
1457                                 col = 0xffffffffffffffff; /* (1.0, 1.0, 1.0) */
1458                         }
1459                         else
1460                         {
1461                                 col = 0x0; /* (0.0, 0.0, 0.0) */
1462                         }
1463                         int index = (y / m_bh) * (m_cuboid_w / m_bw + (m_cuboid_w % m_bw > 0)) +
1464                                                 (x / m_bw);
1465                         src[2 * index] = mask;
1466                         src[2 * index + 1] = col;
1467                 }
1468         }
1469
1470         m_src_data = (glw::GLubyte*)src;
1471 }
1472
1473 void CompressedTexImage2DCase::createTexture (void)
1474 {
1475         glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(),
1476                                                         m_testCtx.getLog());
1477
1478         gl.glGenTextures(1, &tex);
1479         gl.glBindTexture(GL_TEXTURE_2D, tex);
1480         gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1481         gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1482
1483         gl.glPixelStorei(GL_UNPACK_COMPRESSED_BLOCK_SIZE,        m_bs);
1484         gl.glPixelStorei(GL_UNPACK_COMPRESSED_BLOCK_WIDTH,       m_bw);
1485         gl.glPixelStorei(GL_UNPACK_COMPRESSED_BLOCK_HEIGHT, m_bh);
1486
1487         gl.glPixelStorei(GL_UNPACK_ROW_LENGTH,   m_cuboid_w);
1488         gl.glPixelStorei(GL_UNPACK_SKIP_ROWS,    m_subcuboid_y0);
1489         gl.glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_subcuboid_x0);
1490
1491         gl.glCompressedTexImage2D(GL_TEXTURE_2D,
1492                                                           0,
1493                                                           m_internalFormat,
1494                                                           m_subcuboid_w,
1495                                                           m_subcuboid_h,
1496                                                           0,
1497                                                           getImageSize(m_subcuboid_w,
1498                                                                                    m_subcuboid_h,
1499                                                                                    m_subcuboid_d),
1500                                                           m_src_data);
1501
1502         gl.glPixelStorei(GL_UNPACK_COMPRESSED_BLOCK_SIZE,        0);
1503         gl.glPixelStorei(GL_UNPACK_COMPRESSED_BLOCK_WIDTH,       0);
1504         gl.glPixelStorei(GL_UNPACK_COMPRESSED_BLOCK_HEIGHT,  0);
1505
1506         gl.glPixelStorei(GL_UNPACK_ROW_LENGTH,   0);
1507         gl.glPixelStorei(GL_UNPACK_SKIP_ROWS,    0);
1508         gl.glPixelStorei(GL_UNPACK_SKIP_PIXELS,  0);
1509 }
1510
1511 void CompressedTexImage2DCase::createShader (void)
1512 {
1513         glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(),
1514                                                         m_testCtx.getLog());
1515
1516         const tcu::StringTemplate vs_src (vs_template_src);
1517         const tcu::StringTemplate fs_src (fs_template_src);
1518
1519         std::map<std::string,std::string> params;
1520         params["GLSL_VERSION"]   = getGLSLVersionDeclaration(m_glsl_version);
1521         params["TEXCOORDS_TYPE"] = "vec2";
1522         params["LAYER"]                  = "";
1523         params["TEXCOORDS"]              = "pos.xy";
1524         params["SAMPLER_TYPE"]   = "sampler2D";
1525         params["COL_TYPE"]               = "vec4";
1526         params["CONDITION"]              = "colour.rgb == refcolour.rgb";
1527
1528         prog = new glu::ShaderProgram(m_context.getRenderContext(),
1529                                                                   glu::ProgramSources() <<
1530                                                                   glu::VertexSource(vs_src.specialize(params)) <<
1531                                                                   glu::FragmentSource(fs_src.specialize(params)));
1532
1533         if (!prog->isOk())
1534         {
1535                 m_testCtx.getLog()
1536                         << tcu::TestLog::Message << ""
1537                         << tcu::TestLog::EndMessage
1538                         << tcu::TestLog::ShaderProgram(false, "")
1539                         << tcu::TestLog::Shader(QP_SHADER_TYPE_VERTEX,
1540                                                                         prog->getShaderInfo(glu::SHADERTYPE_VERTEX,
1541                                                                                                                 0).source,
1542                                                                         false,
1543                                                                         prog->getShaderInfo(glu::SHADERTYPE_VERTEX,
1544                                                                                                                 0).infoLog)
1545
1546                         << tcu::TestLog::Shader(QP_SHADER_TYPE_FRAGMENT,
1547                                                                         prog->getShaderInfo(glu::SHADERTYPE_FRAGMENT,
1548                                                                                                                 0).source,
1549                                                                         false,
1550                                                                         prog->getShaderInfo(glu::SHADERTYPE_FRAGMENT,
1551                                                                                                                 0).infoLog)
1552                         << tcu::TestLog::EndShaderProgram;
1553                 TCU_FAIL("Shader creation failed");
1554         }
1555
1556         gl.glUseProgram(prog->getProgram());
1557         gl.glUniform1i(gl.glGetUniformLocation(prog->getProgram(), "sampler"), 0);
1558 }
1559
1560 tcu::Surface CompressedTexImage2DCase::renderToSurf (void)
1561 {
1562         glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(),
1563                                                         m_testCtx.getLog());
1564
1565         gl.glClearColor(0.3f, 0.3f, 0.3f, 1.0f);
1566         gl.glClear(GL_COLOR_BUFFER_BIT);
1567
1568         static const float vertexPositions[4*3] =
1569         {
1570                 -1.0, -1.0, -1.0f,
1571                  1.0, -1.0,      0.0f,
1572                 -1.0,  1.0,      0.0f,
1573                  1.0,  1.0,      1.0f,
1574         };
1575
1576         static const deUint16 indices[6] = { 0, 1, 2, 2, 1, 3 };
1577
1578         const glu::VertexArrayBinding attrBindings[] =
1579         {
1580                 glu::va::Float("pos", 3, 4, 0, &vertexPositions[0])
1581         };
1582
1583         gl.glViewport(0, 0, m_subcuboid_w, m_subcuboid_h);
1584
1585         glw::GLfloat refcol = 1.0f;
1586
1587         gl.glUniform4f(gl.glGetUniformLocation(prog->getProgram(), "refcolour"),
1588                                    refcol, refcol, refcol, 1.0f);
1589
1590         glu::draw(m_context.getRenderContext(),
1591                           prog->getProgram(),
1592                           DE_LENGTH_OF_ARRAY(attrBindings),
1593                           &attrBindings[0],
1594                           glu::pr::Triangles(DE_LENGTH_OF_ARRAY(indices), &indices[0]));
1595
1596         tcu::Surface dst;
1597         dst.setSize(m_subcuboid_w, m_subcuboid_h);
1598
1599         glu::readPixels(m_context.getRenderContext(), 0, 0, dst.getAccess());
1600
1601         return dst;
1602 }
1603
1604 void CompressedTexImage2DCase::cleanup (void)
1605 {
1606         glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(),
1607                                                         m_testCtx.getLog());
1608
1609         gl.glDeleteTextures(1, &tex);
1610         delete[] m_src_data;
1611         delete prog;
1612 }
1613
1614 class CompressedTexImage3DCase : public deqp::TestCase
1615                                                            , public sglr::ContextWrapper
1616                                                            , public CompressedTexImageUtils
1617 {
1618 public:
1619         CompressedTexImage3DCase (deqp::Context& context, const char *name, const char *desc,
1620                                                           deUint32 internalFormat,
1621                                                           int cuboid_w, int cuboid_h, int cuboid_d,
1622                                                           int subcuboid_x0, int subcuboid_y0, int subcuboid_z0,
1623                                                           int subcuboid_w, int subcuboid_h, int subcuboid_d,
1624                                                           glu::GLSLVersion glsl_version);
1625         ~CompressedTexImage3DCase (void);
1626         IterateResult iterate (void);
1627 protected:
1628         void generateSrcData_s3tc (void);
1629         void generateSrcData_astc (void);
1630         void createTexture (void);
1631         void createShader (void);
1632         tcu::Surface renderToSurf (int layer);
1633         void cleanup (void);
1634 };
1635
1636 CompressedTexImage3DCase::CompressedTexImage3DCase (deqp::Context& context,
1637                                                                                                         const char *name,
1638                                                                                                         const char *desc,
1639                                                                                                         deUint32 internalFormat,
1640                                                                                                         int cuboid_w,
1641                                                                                                         int cuboid_h,
1642                                                                                                         int cuboid_d,
1643                                                                                                         int subcuboid_x0,
1644                                                                                                         int subcuboid_y0,
1645                                                                                                         int subcuboid_z0,
1646                                                                                                         int subcuboid_w,
1647                                                                                                         int subcuboid_h,
1648                                                                                                         int subcuboid_d,
1649                                                                                                         glu::GLSLVersion glsl_version)
1650         : TestCase(context, name, desc)
1651         , CompressedTexImageUtils(internalFormat,
1652                                                           cuboid_w,
1653                                                           cuboid_h,
1654                                                           cuboid_d,
1655                                                           subcuboid_x0,
1656                                                           subcuboid_y0,
1657                                                           subcuboid_z0,
1658                                                           subcuboid_w,
1659                                                           subcuboid_h,
1660                                                           subcuboid_d,
1661                                                           glsl_version)
1662 {
1663 }
1664
1665 CompressedTexImage3DCase::~CompressedTexImage3DCase (void)
1666 {
1667 }
1668
1669 CompressedTexImage3DCase::IterateResult CompressedTexImage3DCase::iterate (void)
1670 {
1671         glu::RenderContext& renderCtx = TestCase::m_context.getRenderContext();
1672         const glu::ContextInfo& ctxInfo = m_context.getContextInfo();
1673         tcu::TestLog& log = m_testCtx.getLog();
1674         tcu::Surface dst, errMask;
1675
1676         bool pass = true;
1677
1678         sglr::GLContext gl_ctx (renderCtx,
1679                                                         log,
1680                                                         sglr::GLCONTEXT_LOG_CALLS,
1681                                                         tcu::IVec4(0, 0, m_subcuboid_w, m_subcuboid_h));
1682
1683         setContext((sglr::Context*)&gl_ctx);
1684
1685         switch (m_internalFormat)
1686         {
1687         case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
1688                 if (!ctxInfo.isExtensionSupported("GL_EXT_texture_compression_s3tc"))
1689                 {
1690                         m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED,
1691                                                                         "GL_EXT_texture_compression_s3tc extension is not supported");
1692                         return STOP;
1693                 }
1694
1695                 m_bw = 4;
1696                 m_bh = 4;
1697                 m_bd = 1;
1698                 m_bs = 8;
1699
1700                 generateSrcData_s3tc();
1701                 break;
1702         case GL_COMPRESSED_RGBA_ASTC_8x5_KHR:
1703                 if (!ctxInfo.isExtensionSupported("GL_KHR_texture_compression_astc_ldr"))
1704                 {
1705                         m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED,
1706                                                                         "GL_KHR_texture_compression_astc_ldr extension is not supported");
1707                         return STOP;
1708                 }
1709                 m_bw = 8;
1710                 m_bh = 5;
1711                 m_bd = 1;
1712                 m_bs = 16;
1713
1714                 generateSrcData_astc();
1715                 break;
1716         default:
1717                 TCU_FAIL("Invalid internal format");
1718                 break;
1719         }
1720
1721         createTexture();
1722         createShader();
1723
1724         for (int z = 0; z < m_subcuboid_d; z++)
1725         {
1726                 dst = renderToSurf(z);
1727
1728                 bool layer_pass = verify(dst, &errMask);
1729
1730                 if (layer_pass)
1731                 {
1732                         m_testCtx.getLog()
1733                                 << tcu::TestLog::Message << "Layer " << z        << " is valid"
1734                                 << tcu::TestLog::EndMessage
1735                                 << tcu::TestLog::ImageSet("LayerVerification", "Layer verification")
1736                                 << tcu::TestLog::Image("Result", "Rendered result", dst.getAccess())
1737                                 << tcu::TestLog::EndImageSet;
1738                 }
1739                 else
1740                 {
1741                         m_testCtx.getLog()
1742                                 << tcu::TestLog::Message << "Layer " << z << " is invalid"
1743                                 << tcu::TestLog::EndMessage
1744                                 << tcu::TestLog::ImageSet("ErrorVerification", "Layer verification")
1745                                 << tcu::TestLog::Image("Result", "Rendered result", dst.getAccess())
1746                                 << tcu::TestLog::Image("ErrorMask", "Error mask", errMask.getAccess())
1747                                 << tcu::TestLog::EndImageSet;
1748                 }
1749
1750                 pass &= layer_pass;
1751         }
1752
1753         cleanup();
1754
1755         if (pass)
1756         {
1757                 m_testCtx.getLog()
1758                         << tcu::TestLog::Message << "Image is valid" << tcu::TestLog::EndMessage;
1759         }
1760         else
1761         {
1762                 m_testCtx.getLog()
1763                         << tcu::TestLog::Message << "Image is invalid" << tcu::TestLog::EndMessage;
1764         }
1765
1766         m_testCtx.setTestResult(pass ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
1767                                                         pass ? "Pass" : "Fail");
1768
1769         return STOP;
1770 }
1771
1772 void CompressedTexImage3DCase::generateSrcData_s3tc()
1773 {
1774         deUint64 *src = new deUint64[m_cuboid_w / m_bw *
1775                                                                  m_cuboid_h / m_bh *
1776                                                                  m_cuboid_d / m_bd];
1777
1778         deUint64 col_list[] =
1779         {
1780                 0x18E3,                                 /* (0.125, 0.125, 0.125) */
1781                 0x39E7,                                 /* (0.250, 0.250, 0.250) */
1782                 0x5AEB,                                 /* (0.375, 0.375, 0.375) */
1783                 0x7BEF,                                 /* (0.500, 0.500, 0.500) */
1784                 0x9CF3,                                 /* (0.625, 0.625, 0.625) */
1785                 0xBDF7,                                 /* (0.750, 0.750, 0.750) */
1786                 0xDEFB,                                 /* (0.875, 0.875, 0.875) */
1787                 0xffff,                                 /* (1.000, 1.000, 1.000) */
1788         };
1789
1790         deUint64 col = 0x0;
1791
1792         for (int z = 0; z < m_cuboid_d; z += m_bd)
1793         {
1794                 for (int y = 0; y < m_cuboid_h; y += m_bh)
1795                 {
1796                         for (int x = 0; x < m_cuboid_w; x += m_bw)
1797                         {
1798                                 if (inrange(x, m_subcuboid_x0, m_subcuboid_x0 + m_subcuboid_w) &&
1799                                         inrange(y, m_subcuboid_y0, m_subcuboid_y0 + m_subcuboid_h) &&
1800                                         inrange(z, m_subcuboid_z0, m_subcuboid_z0 + m_subcuboid_d))
1801                                         col = col_list[z % 8];
1802                                 else
1803                                         col = 0x0;
1804
1805                                 int index = (z / m_bd) * (m_cuboid_h / m_bh) * (m_cuboid_w / m_bw) +
1806                                                         (y / m_bh) * (m_cuboid_w / m_bw) +
1807                                                         (x / m_bw);
1808                                 src[index] = col;
1809                         }
1810                 }
1811         }
1812
1813         m_src_data = (glw::GLubyte*)src;
1814 }
1815
1816 void CompressedTexImage3DCase::generateSrcData_astc (void)
1817 {
1818         deUint64 col_list[] =
1819         {
1820                 0xffff1fff1fff1fff,             /* (0.125, 0.125, 0.125) */
1821                 0xffff3fff3fff3fff,             /* (0.250, 0.250, 0.250) */
1822                 0xffff5fff5fff5fff,             /* (0.375, 0.375, 0.375) */
1823                 0xffff7fff7fff7fff,             /* (0.500, 0.500, 0.500) */
1824                 0xffff9fff9fff9fff,             /* (0.625, 0.625, 0.625) */
1825                 0xffffbfffbfffbfff,             /* (0.750, 0.750, 0.750) */
1826                 0xffffdfffdfffdfff,             /* (0.875, 0.875, 0.875) */
1827                 0xffffffffffffffff,             /* (1.000, 1.000, 1.000) */
1828         };
1829         deUint64 col = 0x0;
1830         deUint64 mask = 0xFFFFFFFFFFFFFDFC;
1831
1832         int img_size = 2 * (m_cuboid_w / m_bw + (m_cuboid_w % m_bw > 0)) *
1833                                            (m_cuboid_h / m_bh + (m_cuboid_h % m_bh > 0)) *
1834                                            (m_cuboid_d / m_bd + (m_cuboid_d % m_bd > 0));
1835
1836         deUint64 *src = new deUint64[img_size];
1837
1838         for (int z = 0; z < m_cuboid_d; z += m_bd)
1839         {
1840                 for (int y = 0; y < m_cuboid_h; y += m_bh)
1841                 {
1842                         for (int x = 0; x < m_cuboid_w; x += m_bw)
1843                         {
1844                                 if (inrange(x, m_subcuboid_x0, m_subcuboid_x0 + m_subcuboid_w) &&
1845                                         inrange(y, m_subcuboid_y0, m_subcuboid_y0 + m_subcuboid_h) &&
1846                                         inrange(z, m_subcuboid_z0, m_subcuboid_z0 + m_subcuboid_d))
1847                                         col = col_list[z % 8];
1848                                 else
1849                                         col = 0x0;
1850
1851                                 int index = (z / m_bd) * (m_cuboid_h / m_bh + (m_cuboid_h % m_bh > 0)) *
1852                                                                                  (m_cuboid_w / m_bw + (m_cuboid_w % m_bw > 0)) +
1853                                                         (y / m_bh) * (m_cuboid_w / m_bw + (m_cuboid_w % m_bw > 0)) +
1854                                                         (x / m_bw);
1855                                 src[2 * index] = mask;
1856                                 src[2 * index + 1] = col;
1857                         }
1858                 }
1859         }
1860
1861         m_src_data = (glw::GLubyte*)src;
1862 }
1863
1864 void CompressedTexImage3DCase::createTexture (void)
1865 {
1866         glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(),
1867                                                         m_testCtx.getLog());
1868
1869         gl.glGenTextures(1, &tex);
1870         gl.glBindTexture(GL_TEXTURE_2D_ARRAY, tex);
1871         gl.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1872         gl.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1873
1874         gl.glPixelStorei(GL_UNPACK_COMPRESSED_BLOCK_SIZE,        m_bs);
1875         gl.glPixelStorei(GL_UNPACK_COMPRESSED_BLOCK_WIDTH,       m_bw);
1876         gl.glPixelStorei(GL_UNPACK_COMPRESSED_BLOCK_HEIGHT,  m_bh);
1877         gl.glPixelStorei(GL_UNPACK_COMPRESSED_BLOCK_DEPTH,       m_bd);
1878
1879         gl.glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, m_cuboid_h);
1880         gl.glPixelStorei(GL_UNPACK_ROW_LENGTH,   m_cuboid_w);
1881         gl.glPixelStorei(GL_UNPACK_SKIP_IMAGES,  m_subcuboid_z0);
1882         gl.glPixelStorei(GL_UNPACK_SKIP_ROWS,    m_subcuboid_y0);
1883         gl.glPixelStorei(GL_UNPACK_SKIP_PIXELS,  m_subcuboid_x0);
1884
1885         gl.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY,
1886                                                           0,
1887                                                           m_internalFormat,
1888                                                           m_subcuboid_w,
1889                                                           m_subcuboid_h,
1890                                                           m_subcuboid_d,
1891                                                           0,
1892                                                           getImageSize(m_subcuboid_w,
1893                                                                                    m_subcuboid_h,
1894                                                                                    m_subcuboid_d),
1895                                                           m_src_data);
1896
1897         gl.glPixelStorei(GL_UNPACK_COMPRESSED_BLOCK_SIZE,        0);
1898         gl.glPixelStorei(GL_UNPACK_COMPRESSED_BLOCK_WIDTH,       0);
1899         gl.glPixelStorei(GL_UNPACK_COMPRESSED_BLOCK_HEIGHT,  0);
1900         gl.glPixelStorei(GL_UNPACK_COMPRESSED_BLOCK_DEPTH,       0);
1901
1902         gl.glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, 0);
1903         gl.glPixelStorei(GL_UNPACK_ROW_LENGTH,   0);
1904         gl.glPixelStorei(GL_UNPACK_SKIP_IMAGES,  0);
1905         gl.glPixelStorei(GL_UNPACK_SKIP_ROWS,    0);
1906         gl.glPixelStorei(GL_UNPACK_SKIP_PIXELS,  0);
1907 }
1908
1909 void CompressedTexImage3DCase::createShader (void)
1910 {
1911         glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(),
1912                                                         m_testCtx.getLog());
1913
1914         const tcu::StringTemplate vs_src (vs_template_src);
1915         const tcu::StringTemplate fs_src (fs_template_src);
1916
1917         std::map<std::string,std::string> params;
1918         params["GLSL_VERSION"]   = getGLSLVersionDeclaration(m_glsl_version);
1919         params["TEXCOORDS_TYPE"] = "vec3";
1920         params["LAYER"]                  = "uniform int layer;";
1921         params["TEXCOORDS"]              = "vec3(pos.xy, layer)";
1922         params["SAMPLER_TYPE"]   = "sampler2DArray";
1923         params["COL_TYPE"]               = "vec4";
1924
1925         const tcu::StringTemplate fs_condition ("all(lessThan((abs(colour - refcolour)).rgb, vec3(${EPS})))");
1926         std::map<std::string,std::string> fs_condition_params;
1927         fs_condition_params["EPS"] = std::to_string(getEps(m_internalFormat));
1928         params["CONDITION"] = fs_condition.specialize(fs_condition_params);
1929
1930         prog = new glu::ShaderProgram(m_context.getRenderContext(),
1931                                                                   glu::ProgramSources() <<
1932                                                                   glu::VertexSource(vs_src.specialize(params)) <<
1933                                                                   glu::FragmentSource(fs_src.specialize(params)));
1934
1935         if (!prog->isOk())
1936         {
1937                 m_testCtx.getLog()
1938                         << tcu::TestLog::Message << ""
1939                         << tcu::TestLog::EndMessage
1940                         << tcu::TestLog::ShaderProgram(false, "")
1941                         << tcu::TestLog::Shader(QP_SHADER_TYPE_VERTEX,
1942                                                                         prog->getShaderInfo(glu::SHADERTYPE_VERTEX,
1943                                                                                                                 0).source,
1944                                                                         false,
1945                                                                         prog->getShaderInfo(glu::SHADERTYPE_VERTEX,
1946                                                                                                                 0).infoLog)
1947
1948                         << tcu::TestLog::Shader(QP_SHADER_TYPE_FRAGMENT,
1949                                                                         prog->getShaderInfo(glu::SHADERTYPE_FRAGMENT,
1950                                                                                                                 0).source,
1951                                                                         false,
1952                                                                         prog->getShaderInfo(glu::SHADERTYPE_FRAGMENT,
1953                                                                                                                 0).infoLog)
1954                         << tcu::TestLog::EndShaderProgram;
1955                 TCU_FAIL("Shader creation failed");
1956         }
1957
1958         gl.glUseProgram(prog->getProgram());
1959         gl.glUniform1i(gl.glGetUniformLocation(prog->getProgram(), "sampler"), 0);
1960 }
1961
1962 tcu::Surface CompressedTexImage3DCase::renderToSurf (int layer)
1963 {
1964         glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(),
1965                                                         m_testCtx.getLog());
1966
1967         gl.glClearColor(0.3f, 0.3f, 0.3f, 1.0f);
1968         gl.glClear(GL_COLOR_BUFFER_BIT);
1969
1970         static const float vertexPositions[4*3] =
1971         {
1972                 -1.0, -1.0, -1.0f,
1973                  1.0, -1.0,      0.0f,
1974                 -1.0,  1.0,      0.0f,
1975                  1.0,  1.0,      1.0f,
1976         };
1977
1978         static const deUint16 indices[6] = { 0, 1, 2, 2, 1, 3 };
1979
1980         const glu::VertexArrayBinding attrBindings[] =
1981         {
1982                 glu::va::Float("pos", 3, 4, 0, &vertexPositions[0])
1983         };
1984
1985         gl.glViewport(0, 0, m_subcuboid_w, m_subcuboid_h);
1986
1987         gl.glUniform1i(gl.glGetUniformLocation(prog->getProgram(), "layer"), layer);
1988
1989         glw::GLfloat refcols[8] = { 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1.0 };
1990         glw::GLfloat refcol = refcols[(layer + m_subcuboid_z0 % 8) % 8];
1991
1992         gl.glUniform4f(gl.glGetUniformLocation(prog->getProgram(), "refcolour"),
1993                                    refcol, refcol, refcol, 1.0f);
1994
1995         glu::draw(m_context.getRenderContext(),
1996                           prog->getProgram(),
1997                           DE_LENGTH_OF_ARRAY(attrBindings),
1998                           &attrBindings[0],
1999                           glu::pr::Triangles(DE_LENGTH_OF_ARRAY(indices), &indices[0]));
2000
2001         tcu::Surface dst;
2002         dst.setSize(m_subcuboid_w, m_subcuboid_h);
2003
2004         glu::readPixels(m_context.getRenderContext(), 0, 0, dst.getAccess());
2005
2006         return dst;
2007 }
2008
2009 void CompressedTexImage3DCase::cleanup (void)
2010 {
2011         glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(),
2012                                                         m_testCtx.getLog());
2013
2014         gl.glDeleteTextures(1, &tex);
2015         delete[] m_src_data;
2016         delete prog;
2017 }
2018
2019 PixelStorageModesTests::PixelStorageModesTests (deqp::Context& context,
2020                                                                                                 glu::GLSLVersion glsl_version)
2021         : TestCaseGroup(context, "pixelstoragemodes", "Pixel Storage Modes Tests")
2022         , m_glsl_version(glsl_version)
2023 {
2024 }
2025
2026 PixelStorageModesTests::~PixelStorageModesTests (void)
2027 {
2028 }
2029
2030 void PixelStorageModesTests::init(void)
2031 {
2032         const int cuboid_w = 64;
2033         const int cuboid_h = 64;
2034         const int cuboid_d = 64;
2035         const int subcuboid_w = 32;
2036         const int subcuboid_h = 32;
2037         const int subcuboid_d = 8;
2038
2039         struct
2040         {
2041                 const char *name;
2042                 deUint32 internalFmt;
2043         } internalFmts[] =
2044         {
2045                 { "r8",                  GL_R8,                           },
2046                 { "r8snorm",     GL_R8_SNORM,             },
2047                 { "r16f",                GL_R16F,                         },
2048                 { "r32f",                GL_R32F,                         },
2049                 { "r8ui",                GL_R8UI,                         },
2050                 { "r8i",                 GL_R8I,                          },
2051                 { "r16ui",               GL_R16UI,                        },
2052                 { "r16i",                GL_R16I,                         },
2053                 { "r32ui",               GL_R32UI,                        },
2054                 { "r32i",                GL_R32I,                         },
2055                 { "rg8",                 GL_RG8,                          },
2056                 { "rg8snorm",    GL_RG8_SNORM,            },
2057                 { "rg16f",               GL_RG16F,                        },
2058                 { "rg32f",               GL_RG32F,                        },
2059                 { "rg8ui",               GL_RG8UI,                        },
2060                 { "rg8i",                GL_RG8I,                         },
2061                 { "rg16ui",              GL_RG16UI,                       },
2062                 { "rg16i",               GL_RG16I,                        },
2063                 { "rg32ui",              GL_RG32UI,                       },
2064                 { "rg32i",               GL_RG32I,                        },
2065                 { "rgb8",                GL_RGB8,                         },
2066                 { "rgb565",              GL_RGB565,                       },
2067                 { "rgb8snorm",   GL_RGB8_SNORM,           },
2068                 { "r11g11b10f",  GL_R11F_G11F_B10F,       },
2069                 { "rgb16f",              GL_RGB16F,                       },
2070                 { "rgb32f",              GL_RGB32F,                       },
2071                 { "rgb8ui",              GL_RGB8UI,                       },
2072                 { "rgb8i",               GL_RGB8I,                        },
2073                 { "rgb16ui",     GL_RGB16UI,              },
2074                 { "rgb16i",              GL_RGB16I,                       },
2075                 { "rgb32ui",     GL_RGB32UI,              },
2076                 { "rgb32i",              GL_RGB32I,                       },
2077                 { "rgba8",               GL_RGBA8,                        },
2078                 { "rgba8snorm",  GL_RGBA8_SNORM,          },
2079                 { "rgb5a1",              GL_RGB5_A1,              },
2080                 { "rgba4",               GL_RGBA4,                        },
2081                 { "rgb10a2",     GL_RGB10_A2,             },
2082                 { "rgba16f",     GL_RGBA16F,              },
2083                 { "rgba32f",     GL_RGBA32F,              },
2084                 { "rgba8ui",     GL_RGBA8UI,              },
2085                 { "rgba8i",              GL_RGBA8I,                       },
2086                 { "rgb10a2ui",   GL_RGB10_A2UI,           },
2087                 { "rgba16ui",    GL_RGBA16UI,             },
2088                 { "rgba16i",     GL_RGBA16I,              },
2089                 { "rgba32i",     GL_RGBA32I,              },
2090                 { "rgba32ui",    GL_RGBA32UI,             },
2091         };
2092
2093         struct
2094         {
2095                 const char *name;
2096                 deUint32 internalFmt;
2097                 int bw;
2098                 int bh;
2099                 int bd;
2100         } internalFmts_compressed[] =
2101         {
2102                 { "rgb_s3tc_dxt1", GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 4, 4, 1 },
2103                 { "rgba_astc_8x5", GL_COMPRESSED_RGBA_ASTC_8x5_KHR, 8, 5, 1 },
2104         };
2105
2106         tcu::TestCaseGroup* texImage2DGroup = new tcu::TestCaseGroup(m_testCtx,
2107                                                                                                                                  "teximage2d",
2108                                                                                                                                  "glTexImage2D cases");
2109         addChild(texImage2DGroup);
2110
2111         for (int fmts = 0; fmts < DE_LENGTH_OF_ARRAY(internalFmts); fmts++)
2112         {
2113                 tcu::TestCaseGroup* formatsGroup = new tcu::TestCaseGroup(m_testCtx,
2114                                                                                                                                   internalFmts[fmts].name,
2115                                                                                                                                   "");
2116                 texImage2DGroup->addChild(formatsGroup);
2117                 int bw = 1;
2118                 int bh = 1;
2119                 int skip_pixels[3] =
2120                         { 0, bw, bw * (subcuboid_w / (2 * bw)) };
2121                 int skip_rows[3] =
2122                         { 0, bh, bh * (subcuboid_h / (2 * bh)) };
2123
2124                 for (int r = 0; r < 3; r++)
2125                 {
2126                         for (int p = r; p < 3; p++)
2127                         {
2128                                 std::string skip_name =
2129                                         std::to_string(skip_pixels[p]) +
2130                                         "_" +
2131                                         std::to_string(skip_rows[r]);
2132                                 std::string skip_desc =
2133                                         "Skip " +
2134                                         std::to_string(skip_pixels[p]) +
2135                                         " pixels and " +
2136                                         std::to_string(skip_rows[r]) +
2137                                         " rows";
2138                                 formatsGroup->addChild(new TexImage2DCase(m_context,
2139                                                                                                                   skip_name.c_str(),
2140                                                                                                                   skip_desc.c_str(),
2141                                                                                                                   internalFmts[fmts].internalFmt,
2142                                                                                                                   cuboid_w,
2143                                                                                                                   cuboid_h,
2144                                                                                                                   skip_pixels[p],
2145                                                                                                                   skip_rows[r],
2146                                                                                                                   subcuboid_w,
2147                                                                                                                   subcuboid_h,
2148                                                                                                                   m_glsl_version));
2149                         }
2150                 }
2151         }
2152
2153         tcu::TestCaseGroup* texImage3DGroup = new tcu::TestCaseGroup(m_testCtx,
2154                                                                                                                                  "teximage3d",
2155                                                                                                                                  "glTexImage3D cases");
2156         addChild(texImage3DGroup);
2157
2158         for (int fmts = 0; fmts < DE_LENGTH_OF_ARRAY(internalFmts); fmts++)
2159         {
2160                 tcu::TestCaseGroup* formatsGroup = new tcu::TestCaseGroup(m_testCtx,
2161                                                                                                                                   internalFmts[fmts].name,
2162                                                                                                                                   "");
2163                 texImage3DGroup->addChild(formatsGroup);
2164                 int bw = 1;
2165                 int bh = 1;
2166                 int bd = 1;
2167                 int skip_pixels[3] =
2168                         { 0, bw, bw * (subcuboid_w / (2 * bw)) };
2169                 int skip_rows[3] =
2170                         { 0, bh, bh * (subcuboid_h / (2 * bh)) };
2171                 int skip_images[3] =
2172                         { 0, bd, bd * (subcuboid_d / (2 * bd)) };
2173
2174                 for (int i = 0; i < 3; i++)
2175                 {
2176                         for (int r = i; r < 3; r++)
2177                         {
2178                                 for (int p = r; p < 3; p++)
2179                                 {
2180                                         std::string skip_name =
2181                                                 std::to_string(skip_pixels[p]) +
2182                                                 "_" +
2183                                                 std::to_string(skip_rows[r]) +
2184                                                 "_" +
2185                                                 std::to_string(skip_images[i]);
2186                                         std::string skip_desc =
2187                                                 "Skip " +
2188                                                 std::to_string(skip_pixels[p]) +
2189                                                 " pixels, " +
2190                                                 std::to_string(skip_rows[r]) +
2191                                                 " rows, and " +
2192                                                 std::to_string(skip_images[i]) +
2193                                                 " images";
2194                                         formatsGroup->addChild(new TexImage3DCase(m_context,
2195                                                                                                                           skip_name.c_str(),
2196                                                                                                                           skip_desc.c_str(),
2197                                                                                                                           internalFmts[fmts].internalFmt,
2198                                                                                                                           cuboid_w,
2199                                                                                                                           cuboid_h,
2200                                                                                                                           cuboid_d,
2201                                                                                                                           skip_pixels[p],
2202                                                                                                                           skip_rows[r],
2203                                                                                                                           skip_images[i],
2204                                                                                                                           subcuboid_w,
2205                                                                                                                           subcuboid_h,
2206                                                                                                                           subcuboid_d,
2207                                                                                                                           m_glsl_version));
2208                                 }
2209                         }
2210                 }
2211         }
2212
2213         if (!glu::isContextTypeES(m_context.getRenderContext().getType()))
2214         {
2215                 tcu::TestCaseGroup* compressedTexImage2DGroup =
2216                         new tcu::TestCaseGroup(m_testCtx,
2217                                                                    "compressedteximage2d",
2218                                                                    "glCompressedTexImage2D cases");
2219                 addChild(compressedTexImage2DGroup);
2220
2221                 for (int fmts = 0; fmts < DE_LENGTH_OF_ARRAY(internalFmts_compressed); fmts++)
2222                 {
2223                         tcu::TestCaseGroup* formatsGroup
2224                                 = new tcu::TestCaseGroup(m_testCtx,
2225                                                                                  internalFmts_compressed[fmts].name,
2226                                                                                  "");
2227                         compressedTexImage2DGroup->addChild(formatsGroup);
2228                         int bw = internalFmts_compressed[fmts].bw;
2229                         int bh = internalFmts_compressed[fmts].bh;
2230                         int skip_pixels[4] =
2231                                 { 0, bw, bw * (subcuboid_w / (2 * bw)), bw * (subcuboid_w / bw) };
2232                         int skip_rows[4] =
2233                                 { 0, bh, bh * (subcuboid_h / (2 * bh)), bh * (subcuboid_h / bh) };
2234                         for (int r = 0; r < 4; r++)
2235                         {
2236                                 for (int p = 0; p < 4; p++)
2237                                 {
2238                                         std::string skip_name =
2239                                                 std::to_string(skip_pixels[p]) +
2240                                                 "_" +
2241                                                 std::to_string(skip_rows[r]);
2242                                         std::string skip_desc =
2243                                                 "Skip " +
2244                                                 std::to_string(skip_pixels[p]) +
2245                                                 " pixels and " +
2246                                                 std::to_string(skip_rows[r]) +
2247                                                 " rows";
2248                                         formatsGroup->addChild(new CompressedTexImage2DCase(
2249                                                                                           m_context,
2250                                                                                           skip_name.c_str(),
2251                                                                                           skip_desc.c_str(),
2252                                                                                           internalFmts_compressed[fmts].internalFmt,
2253                                                                                           cuboid_w,
2254                                                                                           cuboid_h,
2255                                                                                           skip_pixels[p],
2256                                                                                           skip_rows[r],
2257                                                                                           subcuboid_w,
2258                                                                                           subcuboid_h,
2259                                                                                           m_glsl_version));
2260                                 }
2261                         }
2262                 }
2263
2264                 tcu::TestCaseGroup* compressedTexImage3DGroup =
2265                         new tcu::TestCaseGroup(m_testCtx,
2266                                                                    "compressedteximage3d",
2267                                                                    "glCompressedTexImage3D cases");
2268                 addChild(compressedTexImage3DGroup);
2269
2270                 for (int fmts = 0; fmts < DE_LENGTH_OF_ARRAY(internalFmts_compressed); fmts++)
2271                 {
2272                         tcu::TestCaseGroup* formatsGroup
2273                                 = new tcu::TestCaseGroup(m_testCtx,
2274                                                                                  internalFmts_compressed[fmts].name,
2275                                                                                  "");
2276                         compressedTexImage3DGroup->addChild(formatsGroup);
2277                         int bw = internalFmts_compressed[fmts].bw;
2278                         int bh = internalFmts_compressed[fmts].bh;
2279                         int bd = internalFmts_compressed[fmts].bd;
2280                         int skip_pixels[4] =
2281                                 { 0, bw, bw * (subcuboid_w / (2 * bw)), bw * (subcuboid_w / bw) };
2282                         int skip_rows[4] =
2283                                 { 0, bh, bh * (subcuboid_h / (2 * bh)), bh * (subcuboid_h / bh) };
2284                         int skip_images[4] =
2285                                 { 0, bd, bd * (subcuboid_d / (2 * bd)), bd * (subcuboid_d / bd) };
2286                         for (int i = 0; i < 4; i++)
2287                         {
2288                                 for (int r = 0; r < 4; r++)
2289                                 {
2290                                         for (int p = 0; p < 4; p++)
2291                                         {
2292                                                 std::string skip_name =
2293                                                         std::to_string(skip_pixels[p]) +
2294                                                         "_" +
2295                                                         std::to_string(skip_rows[r]) +
2296                                                         "_" +
2297                                                         std::to_string(skip_images[i]);
2298                                                 std::string skip_desc =
2299                                                         "Skip " +
2300                                                         std::to_string(skip_pixels[p]) +
2301                                                         " pixels, " +
2302                                                         std::to_string(skip_rows[r]) +
2303                                                         " rows, and " +
2304                                                         std::to_string(skip_images[i]) +
2305                                                         " images";
2306                                                 formatsGroup->addChild(new CompressedTexImage3DCase(
2307                                                                                                   m_context,
2308                                                                                                   skip_name.c_str(),
2309                                                                                                   skip_desc.c_str(),
2310                                                                                                   internalFmts_compressed[fmts].internalFmt,
2311                                                                                                   cuboid_w,
2312                                                                                                   cuboid_h,
2313                                                                                                   cuboid_d,
2314                                                                                                   skip_pixels[p],
2315                                                                                                   skip_rows[r],
2316                                                                                                   skip_images[i],
2317                                                                                                   subcuboid_w,
2318                                                                                                   subcuboid_h,
2319                                                                                                   subcuboid_d,
2320                                                                                                   m_glsl_version));
2321                                         }
2322                                 }
2323                         }
2324                 }
2325         }
2326 }
2327
2328 } /* namespace glcts */