xref: /aosp_15_r20/external/deqp/external/openglcts/modules/gl/gl3cGLSLnoperspectiveTests.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 /*-------------------------------------------------------------------------
2  * OpenGL Conformance Test Suite
3  * -----------------------------
4  *
5  * Copyright (c) 2015-2016 The Khronos Group Inc.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */ /*!
20  * \file
21  * \brief
22  */ /*-------------------------------------------------------------------*/
23 
24 /**
25  * \file  gl3cGLSLnoperspectiveTests.cpp
26  * \brief Implements conformance tests for "GLSL no perspective" functionality.
27  */ /*-------------------------------------------------------------------*/
28 
29 #include "gl3cGLSLnoperspectiveTests.hpp"
30 #include "gluContextInfo.hpp"
31 #include "glwFunctions.hpp"
32 #include "tcuTestLog.hpp"
33 
34 namespace gl3cts
35 {
36 /** Compiles shader
37  *
38  * @param context     Context of test framework
39  * @param shader_id   Shader id
40  * @param shader_code Shader source code
41  **/
compile_shader(deqp::Context & context,glw::GLuint shader_id,const glw::GLchar * shader_code)42 void compile_shader(deqp::Context &context, glw::GLuint shader_id, const glw::GLchar *shader_code)
43 {
44     /* GL entry points */
45     const glw::Functions &gl = context.getRenderContext().getFunctions();
46 
47     /* Compilation status */
48     glw::GLint status = GL_FALSE;
49 
50     /* Set source code */
51     gl.shaderSource(shader_id, 1 /* count */, &shader_code, 0);
52     GLU_EXPECT_NO_ERROR(gl.getError(), "ShaderSource");
53 
54     /* Compile */
55     gl.compileShader(shader_id);
56     GLU_EXPECT_NO_ERROR(gl.getError(), "CompileShader");
57 
58     /* Get compilation status */
59     gl.getShaderiv(shader_id, GL_COMPILE_STATUS, &status);
60     GLU_EXPECT_NO_ERROR(gl.getError(), "GetShaderiv");
61 
62     /* Log compilation error */
63     if (GL_TRUE != status)
64     {
65         glw::GLint length = 0;
66         std::vector<glw::GLchar> message;
67 
68         /* Error log length */
69         gl.getShaderiv(shader_id, GL_INFO_LOG_LENGTH, &length);
70         GLU_EXPECT_NO_ERROR(gl.getError(), "GetShaderiv");
71 
72         /* Prepare storage */
73         message.resize(length);
74 
75         /* Get error log */
76         gl.getShaderInfoLog(shader_id, length, 0, &message[0]);
77         GLU_EXPECT_NO_ERROR(gl.getError(), "GetShaderInfoLog");
78 
79         /* Log */
80         context.getTestContext().getLog()
81             << tcu::TestLog::Message << "Failed to compile shader:\n"
82             << &message[0] << tcu::TestLog::EndMessage << tcu::TestLog::KernelSource(shader_code);
83 
84         TCU_FAIL("Failed to compile shader");
85     }
86 }
87 
88 /** Creates and compiles shader
89  *
90  * @param context Context of test framework
91  * @param stage   Shader stage
92  * @param code    Shader source code
93  *
94  * @return Id of created shader
95  **/
prepare_shader(deqp::Context & context,glw::GLenum stage,const glw::GLchar * code)96 glw::GLuint prepare_shader(deqp::Context &context, glw::GLenum stage, const glw::GLchar *code)
97 {
98     /* GL entry points */
99     const glw::Functions &gl = context.getRenderContext().getFunctions();
100 
101     /* Compilation status */
102     glw::GLuint id = 0;
103 
104     /* Create */
105     id = gl.createShader(stage);
106     GLU_EXPECT_NO_ERROR(gl.getError(), "CreateShader");
107 
108     try
109     {
110         compile_shader(context, id, code);
111     }
112     catch (const std::exception &exc)
113     {
114         gl.deleteShader(id);
115         GLU_EXPECT_NO_ERROR(gl.getError(), "DeleteShader");
116 
117         TCU_FAIL(exc.what());
118     }
119 
120     return id;
121 }
122 
123 /** Attach shaders and link program
124  *
125  * @param context            Context of test framework
126  * @param fragment_shader_id Id of fragment shader
127  * @param vertex_shader_id   Id of vertex shader
128  * @param program_object_id  Id of program object
129  **/
link_program(deqp::Context & context,glw::GLuint fragment_shader_id,glw::GLuint vertex_shader_id,glw::GLuint program_object_id)130 void link_program(deqp::Context &context, glw::GLuint fragment_shader_id, glw::GLuint vertex_shader_id,
131                   glw::GLuint program_object_id)
132 {
133     /* GL entry points */
134     const glw::Functions &gl = context.getRenderContext().getFunctions();
135 
136     /* Link status */
137     glw::GLint status = GL_FALSE;
138 
139     /* Attach shaders */
140     if (0 != fragment_shader_id)
141     {
142         gl.attachShader(program_object_id, fragment_shader_id);
143         GLU_EXPECT_NO_ERROR(gl.getError(), "AttachShader");
144     }
145 
146     if (0 != vertex_shader_id)
147     {
148         gl.attachShader(program_object_id, vertex_shader_id);
149         GLU_EXPECT_NO_ERROR(gl.getError(), "AttachShader");
150     }
151 
152     /* Link */
153     gl.linkProgram(program_object_id);
154     GLU_EXPECT_NO_ERROR(gl.getError(), "LinkProgram");
155 
156     /* Get link status */
157     gl.getProgramiv(program_object_id, GL_LINK_STATUS, &status);
158     GLU_EXPECT_NO_ERROR(gl.getError(), "GetProgramiv");
159 
160     /* Log link error */
161     if (GL_TRUE != status)
162     {
163         glw::GLint length = 0;
164         std::vector<glw::GLchar> message;
165 
166         /* Get error log length */
167         gl.getProgramiv(program_object_id, GL_INFO_LOG_LENGTH, &length);
168         GLU_EXPECT_NO_ERROR(gl.getError(), "GetProgramiv");
169 
170         message.resize(length);
171 
172         /* Get error log */
173         gl.getProgramInfoLog(program_object_id, length, 0, &message[0]);
174         GLU_EXPECT_NO_ERROR(gl.getError(), "GetProgramInfoLog");
175 
176         /* Log */
177         context.getTestContext().getLog() << tcu::TestLog::Message << "Failed to link program:\n"
178                                           << &message[0] << tcu::TestLog::EndMessage;
179 
180         TCU_FAIL("Failed to link program");
181     }
182 }
183 
184 /** Create and build program
185  *
186  * @param context              Context of test framework
187  * @param fragment_shader_code Fragment shader source code
188  * @param vertex_shader_code   Vertex shader source code
189  *
190  * @return Id of program object
191  **/
prepare_program(deqp::Context & context,const glw::GLchar * fragment_shader_code,const glw::GLchar * vertex_shader_code)192 glw::GLuint prepare_program(deqp::Context &context, const glw::GLchar *fragment_shader_code,
193                             const glw::GLchar *vertex_shader_code)
194 {
195     /* GL entry points */
196     const glw::Functions &gl = context.getRenderContext().getFunctions();
197 
198     glw::GLuint fragment_shader_id = 0;
199     glw::GLuint program_object_id  = 0;
200     glw::GLuint vertex_shader_id   = 0;
201 
202     try
203     {
204         /* Create shader objects and compile */
205         if (0 != fragment_shader_code)
206         {
207             fragment_shader_id = prepare_shader(context, GL_FRAGMENT_SHADER, fragment_shader_code);
208         }
209 
210         if (0 != vertex_shader_code)
211         {
212             vertex_shader_id = prepare_shader(context, GL_VERTEX_SHADER, vertex_shader_code);
213         }
214 
215         /* Create program object */
216         program_object_id = gl.createProgram();
217         GLU_EXPECT_NO_ERROR(gl.getError(), "CreateProgram");
218 
219         /* Link program */
220         link_program(context, fragment_shader_id, vertex_shader_id, program_object_id);
221     }
222     catch (const std::exception &exc)
223     {
224         if (0 != program_object_id)
225             gl.deleteProgram(program_object_id);
226         if (0 != fragment_shader_id)
227             gl.deleteShader(fragment_shader_id);
228         if (0 != vertex_shader_id)
229             gl.deleteShader(vertex_shader_id);
230 
231         TCU_FAIL(exc.what());
232     }
233 
234     /* Shader ids can now be deleted */
235     if (0 != fragment_shader_id)
236         gl.deleteShader(fragment_shader_id);
237     if (0 != vertex_shader_id)
238         gl.deleteShader(vertex_shader_id);
239 
240     /* Done */
241     return program_object_id;
242 }
243 
244 /** Constructor.
245  *
246  *  @param context Rendering context.
247  *
248  **/
FunctionalTest(deqp::Context & context)249 FunctionalTest::FunctionalTest(deqp::Context &context)
250     : TestCase(context, "functionaltest", "Verifies that interpolation qualifier has imact on results of rendering")
251 {
252     /* Left blank intentionally */
253 }
254 
255 /** Executes test iteration.
256  *
257  *  @return Returns STOP when test has finished executing, CONTINUE if more iterations are needed.
258  */
iterate()259 tcu::TestNode::IterateResult FunctionalTest::iterate()
260 {
261     static const char *vs_default = "#version 130\n"
262                                     "\n"
263                                     "in vec4 in_position;\n"
264                                     "in vec4 in_color;\n"
265                                     "\n"
266                                     "out vec4 vs_fs_color;\n"
267                                     "\n"
268                                     "void main()\n"
269                                     "{\n"
270                                     "    gl_Position = in_position;\n"
271                                     "    vs_fs_color = in_color;\n"
272                                     "}\n"
273                                     "\n";
274 
275     static const char *vs_flat = "#version 130\n"
276                                  "\n"
277                                  "in vec4 in_position;\n"
278                                  "in vec4 in_color;\n"
279                                  "\n"
280                                  "flat out vec4 vs_fs_color;\n"
281                                  "\n"
282                                  "void main()\n"
283                                  "{\n"
284                                  "    gl_Position = in_position;\n"
285                                  "    vs_fs_color = in_color;\n"
286                                  "}\n"
287                                  "\n";
288 
289     static const char *vs_noperspective = "#version 130\n"
290                                           "\n"
291                                           "in vec4 in_position;\n"
292                                           "in vec4 in_color;\n"
293                                           "\n"
294                                           "noperspective out vec4 vs_fs_color;\n"
295                                           "\n"
296                                           "void main()\n"
297                                           "{\n"
298                                           "    gl_Position = in_position;\n"
299                                           "    vs_fs_color = in_color;\n"
300                                           "}\n"
301                                           "\n";
302 
303     static const char *vs_smooth = "#version 130\n"
304                                    "\n"
305                                    "in vec4 in_position;\n"
306                                    "in vec4 in_color;\n"
307                                    "\n"
308                                    "smooth out vec4 vs_fs_color;\n"
309                                    "\n"
310                                    "void main()\n"
311                                    "{\n"
312                                    "    gl_Position = in_position;\n"
313                                    "    vs_fs_color = in_color;\n"
314                                    "}\n"
315                                    "\n";
316 
317     static const char *fs_default = "#version 130\n"
318                                     "\n"
319                                     "in vec4 vs_fs_color;\n"
320                                     "\n"
321                                     "out vec4 out_color;\n"
322                                     "\n"
323                                     "void main()\n"
324                                     "{\n"
325                                     "    out_color = vs_fs_color;\n"
326                                     "}\n"
327                                     "\n";
328 
329     static const char *fs_flat = "#version 130\n"
330                                  "\n"
331                                  "flat in vec4 vs_fs_color;\n"
332                                  "\n"
333                                  "out vec4 out_color;\n"
334                                  "\n"
335                                  "void main()\n"
336                                  "{\n"
337                                  "    out_color = vs_fs_color;\n"
338                                  "}\n"
339                                  "\n";
340 
341     static const char *fs_noperspective = "#version 130\n"
342                                           "\n"
343                                           "noperspective in vec4 vs_fs_color;\n"
344                                           "\n"
345                                           "out vec4 out_color;\n"
346                                           "\n"
347                                           "void main()\n"
348                                           "{\n"
349                                           "    out_color = vs_fs_color;\n"
350                                           "}\n"
351                                           "\n";
352 
353     static const char *fs_smooth = "#version 130\n"
354                                    "\n"
355                                    "smooth in vec4 vs_fs_color;\n"
356                                    "\n"
357                                    "out vec4 out_color;\n"
358                                    "\n"
359                                    "void main()\n"
360                                    "{\n"
361                                    "    out_color = vs_fs_color;\n"
362                                    "}\n"
363                                    "\n";
364 
365     static const glw::GLfloat positions_data[] = {-1.0f, 1.0f,  -1.0f, 1.0f, 3.0f, 3.0f,  3.0f, 3.0f,
366                                                   -1.0f, -1.0f, -1.0f, 1.0f, 3.0f, -3.0f, 3.0f, 3.0f};
367     static const glw::GLubyte colors_data[]    = {0xff, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff,
368                                                   0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
369 
370     const glw::Functions &gl = m_context.getRenderContext().getFunctions();
371 
372     static const char *shaders[][2] = {
373         {vs_noperspective, fs_noperspective}, {vs_default, fs_default}, {vs_flat, fs_flat}, {vs_smooth, fs_smooth}};
374     static const size_t n_shaders          = sizeof(shaders) / sizeof(shaders[0]);
375     static const size_t noperspective_idx  = 0;
376     static const glw::GLsizei w            = 64;
377     static const glw::GLsizei h            = 64;
378     static const glw::GLsizei image_length = w * h;
379 
380     bool test_result = true;
381 
382     glw::GLuint po_ids[n_shaders]  = {0};
383     glw::GLuint tex_ids[n_shaders] = {0};
384     glw::GLuint fbo_ids[n_shaders] = {0};
385     glw::GLuint vab_id             = 0;
386     glw::GLuint vao_id             = 0;
387 
388     try
389     {
390         /* Buffer */
391         gl.genBuffers(1, &vab_id);
392         GLU_EXPECT_NO_ERROR(gl.getError(), "GenBuffers");
393 
394         gl.bindBuffer(GL_ARRAY_BUFFER, vab_id);
395         GLU_EXPECT_NO_ERROR(gl.getError(), "BindBuffer");
396 
397         gl.bufferData(GL_ARRAY_BUFFER, sizeof(colors_data) + sizeof(positions_data), 0 /* data */, GL_STATIC_DRAW);
398         GLU_EXPECT_NO_ERROR(gl.getError(), "BufferData");
399 
400         gl.bufferSubData(GL_ARRAY_BUFFER, 0 /* offset */, sizeof(positions_data) /* size */, positions_data);
401         GLU_EXPECT_NO_ERROR(gl.getError(), "BufferSubData");
402 
403         gl.bufferSubData(GL_ARRAY_BUFFER, sizeof(positions_data) /* offset */, sizeof(colors_data) /* size */,
404                          colors_data);
405         GLU_EXPECT_NO_ERROR(gl.getError(), "BufferSubData");
406 
407         /* FBOs */
408         gl.genFramebuffers(n_shaders, fbo_ids);
409         GLU_EXPECT_NO_ERROR(gl.getError(), "GenFramebuffers");
410 
411         /* Textures */
412         gl.genTextures(n_shaders, tex_ids);
413         GLU_EXPECT_NO_ERROR(gl.getError(), "GenTextures");
414 
415         /* VAO */
416         gl.genVertexArrays(1, &vao_id);
417         GLU_EXPECT_NO_ERROR(gl.getError(), "GenVertexArrays");
418 
419         gl.bindVertexArray(vao_id);
420         GLU_EXPECT_NO_ERROR(gl.getError(), "BindVertexArrays");
421 
422         for (size_t i = 0; i < n_shaders; ++i)
423         {
424             /* Program */
425             po_ids[i] = prepare_program(m_context, shaders[i][1], shaders[i][0]);
426 
427             /* Texture */
428             gl.bindTexture(GL_TEXTURE_2D, tex_ids[i]);
429             GLU_EXPECT_NO_ERROR(gl.getError(), "BindTexture");
430 
431             gl.texImage2D(GL_TEXTURE_2D, 0 /* level */, GL_RGBA8, w, h, 0 /* border */, GL_RGBA, GL_UNSIGNED_BYTE,
432                           0 /* data */);
433             GLU_EXPECT_NO_ERROR(gl.getError(), "TexImage2D");
434 
435             gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
436 
437             gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
438             GLU_EXPECT_NO_ERROR(gl.getError(), "TexParameteri");
439 
440             /* FBO */
441             gl.bindFramebuffer(GL_FRAMEBUFFER, fbo_ids[i]);
442             GLU_EXPECT_NO_ERROR(gl.getError(), "BindFramebuffer");
443 
444             gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex_ids[i], 0 /* level */);
445             GLU_EXPECT_NO_ERROR(gl.getError(), "FramebufferTexture2D");
446 
447             /* Viewport */
448             gl.viewport(0, 0, w, h);
449             GLU_EXPECT_NO_ERROR(gl.getError(), "Viewport");
450 
451             /* VAO */
452             glw::GLint in_position_loc = gl.getAttribLocation(po_ids[i], "in_position");
453             glw::GLint in_color_loc    = gl.getAttribLocation(po_ids[i], "in_color");
454             GLU_EXPECT_NO_ERROR(gl.getError(), "GetAttribLocation");
455             if ((-1 == in_position_loc) || (-1 == in_color_loc))
456             {
457                 TCU_FAIL("Attributes are not available");
458             }
459 
460             gl.vertexAttribPointer(in_position_loc, 4 /* size */, GL_FLOAT, GL_FALSE /* normalizeed */, 0 /* stride */,
461                                    0 /* offset */);
462             GLU_EXPECT_NO_ERROR(gl.getError(), "VertexAttribPointer");
463 
464             gl.vertexAttribPointer(in_color_loc, 4 /* size */, GL_UNSIGNED_BYTE, GL_TRUE /* normalizeed */,
465                                    0 /* stride */, (glw::GLvoid *)sizeof(positions_data) /* offset */);
466             GLU_EXPECT_NO_ERROR(gl.getError(), "VertexAttribPointer");
467 
468             gl.enableVertexAttribArray(in_position_loc);
469             GLU_EXPECT_NO_ERROR(gl.getError(), "EnableVertexAttribArray");
470 
471             gl.enableVertexAttribArray(in_color_loc);
472             GLU_EXPECT_NO_ERROR(gl.getError(), "EnableVertexAttribArray");
473 
474             /* Clear */
475             gl.clearColor(0.0f, 0.0f, 0.0f, 1.0f);
476             GLU_EXPECT_NO_ERROR(gl.getError(), "ClearColor");
477 
478             gl.clear(GL_COLOR_BUFFER_BIT);
479             GLU_EXPECT_NO_ERROR(gl.getError(), "Clear");
480 
481             /* Activate program */
482             gl.useProgram(po_ids[i]);
483             GLU_EXPECT_NO_ERROR(gl.getError(), "UseProgram");
484 
485             /* Draw */
486             gl.drawArrays(GL_TRIANGLE_STRIP, 0 /* first */, 4 /* count */);
487             GLU_EXPECT_NO_ERROR(gl.getError(), "DrawArrays");
488 
489             /* Disable VAO */
490             gl.disableVertexAttribArray(in_position_loc);
491             GLU_EXPECT_NO_ERROR(gl.getError(), "DisableVertexAttribArray");
492 
493             gl.disableVertexAttribArray(in_color_loc);
494             GLU_EXPECT_NO_ERROR(gl.getError(), "DisableVertexAttribArray");
495         }
496 
497         /* Verify results */
498         {
499             /* Storage for images */
500             std::vector<glw::GLuint> fbo_data;
501             std::vector<glw::GLuint> noperspective_data;
502 
503             fbo_data.resize(image_length);
504             noperspective_data.resize(image_length);
505 
506             /* Get noperspective image */
507             gl.bindTexture(GL_TEXTURE_2D, tex_ids[noperspective_idx]);
508             GLU_EXPECT_NO_ERROR(gl.getError(), "BindTexture");
509 
510             gl.getTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, &noperspective_data[0]);
511             GLU_EXPECT_NO_ERROR(gl.getError(), "GetTexImage");
512 
513             /* Compare noperspective with the rest */
514             for (size_t i = 0; i < n_shaders; ++i)
515             {
516                 /* Skip noperspective */
517                 if (noperspective_idx == i)
518                 {
519                     continue;
520                 }
521 
522                 gl.bindTexture(GL_TEXTURE_2D, tex_ids[i]);
523                 GLU_EXPECT_NO_ERROR(gl.getError(), "BindTexture");
524 
525                 gl.getTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, &fbo_data[0]);
526                 GLU_EXPECT_NO_ERROR(gl.getError(), "GetTexImage");
527 
528                 bool are_same = true;
529 
530                 for (size_t pixel = 0; pixel < image_length; ++pixel)
531                 {
532                     const glw::GLuint left  = noperspective_data[pixel];
533                     const glw::GLuint right = fbo_data[pixel];
534 
535                     if (left != right)
536                     {
537                         are_same = false;
538                         break;
539                     }
540                 }
541 
542                 if (true == are_same)
543                 {
544                     test_result = false;
545                     break;
546                 }
547             }
548         }
549 
550         gl.bindBuffer(GL_ARRAY_BUFFER, 0);
551         gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
552         gl.bindTexture(GL_TEXTURE_2D, 0);
553         gl.bindVertexArray(0);
554         gl.useProgram(0);
555 
556         gl.deleteBuffers(1, &vab_id);
557         vab_id = 0;
558 
559         gl.deleteVertexArrays(1, &vao_id);
560         vao_id = 0;
561 
562         gl.deleteFramebuffers(n_shaders, fbo_ids);
563         gl.deleteTextures(n_shaders, tex_ids);
564 
565         for (size_t idx = 0; idx < n_shaders; ++idx)
566         {
567             fbo_ids[idx] = 0;
568             tex_ids[idx] = 0;
569         }
570 
571         for (size_t i = 0; i < n_shaders; ++i)
572         {
573             if (0 != po_ids[i])
574             {
575                 gl.deleteProgram(po_ids[i]);
576                 po_ids[i] = 0;
577             }
578         }
579     }
580     catch (...)
581     {
582         /* Unbind */
583         gl.bindBuffer(GL_ARRAY_BUFFER, 0);
584 
585         gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
586 
587         gl.bindTexture(GL_TEXTURE_2D, 0);
588 
589         gl.bindVertexArray(0);
590 
591         gl.useProgram(0);
592 
593         /* Delete */
594         if (0 != vao_id)
595         {
596             gl.deleteVertexArrays(1, &vao_id);
597         }
598 
599         if (0 != vab_id)
600         {
601             gl.deleteBuffers(1, &vab_id);
602         }
603 
604         if (0 != fbo_ids[0])
605         {
606             gl.deleteFramebuffers(n_shaders, fbo_ids);
607         }
608 
609         for (size_t i = 0; i < n_shaders; ++i)
610         {
611             if (0 != po_ids[i])
612             {
613                 gl.deleteProgram(po_ids[i]);
614             }
615         }
616 
617         if (0 != tex_ids[0])
618         {
619             gl.deleteTextures(n_shaders, tex_ids);
620         }
621 
622         /* Clean any error */
623         gl.getError();
624 
625         /* Rethrow */
626         throw;
627     }
628 
629     /* Set test result */
630     if (true == test_result)
631     {
632         m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
633     }
634     else
635     {
636         m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
637     }
638 
639     /* Clean */
640     {
641         /* Unbind */
642         gl.bindBuffer(GL_ARRAY_BUFFER, 0);
643 
644         gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
645 
646         gl.bindTexture(GL_TEXTURE_2D, 0);
647 
648         gl.bindVertexArray(0);
649 
650         gl.useProgram(0);
651 
652         /* Delete */
653         if (0 != vao_id)
654         {
655             gl.deleteVertexArrays(1, &vao_id);
656         }
657 
658         if (0 != vab_id)
659         {
660             gl.deleteBuffers(1, &vab_id);
661         }
662 
663         if (0 != fbo_ids[0])
664         {
665             gl.deleteFramebuffers(1, fbo_ids);
666         }
667 
668         for (size_t i = 0; i < n_shaders; ++i)
669         {
670             if (0 != po_ids[i])
671             {
672                 gl.deleteProgram(po_ids[i]);
673             }
674         }
675 
676         if (0 != tex_ids[0])
677         {
678             gl.deleteTextures(1, tex_ids);
679         }
680     }
681 
682     /* Clean any error */
683     gl.getError();
684 
685     /* Done */
686     return STOP;
687 }
688 
689 /** Constructor.
690  *
691  *  @param context Rendering context.
692  **/
GLSLnoperspectiveTests(deqp::Context & context)693 GLSLnoperspectiveTests::GLSLnoperspectiveTests(deqp::Context &context)
694     : TestCaseGroup(context, "glsl_noperspective", "Verifies \"GLSL_noperspective\" functionality")
695 {
696     /* Left blank on purpose */
697 }
698 
699 /** Initializes a gpu_shader_5 test group.
700  *
701  **/
init(void)702 void GLSLnoperspectiveTests::init(void)
703 {
704     addChild(new FunctionalTest(m_context));
705 }
706 } // namespace gl3cts
707