1 /*-------------------------------------------------------------------------
2 * OpenGL Conformance Test Suite
3 * -----------------------------
5 * Copyright (c) 2015-2016 The Khronos Group Inc.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 */ /*-------------------------------------------------------------------*/
26 * \file gl4cDirectStateAccessXFBTests.cpp
27 * \brief Conformance tests for the Direct State Access feature functionality (Transform Feedbeck access part).
28 */ /*-----------------------------------------------------------------------------------------------------------*/
31 #include "gl4cDirectStateAccessTests.hpp"
33 #include "deSharedPtr.hpp"
35 #include "gluContextInfo.hpp"
36 #include "gluDefs.hpp"
37 #include "gluPixelTransfer.hpp"
38 #include "gluStrUtil.hpp"
40 #include "tcuFuzzyImageCompare.hpp"
41 #include "tcuImageCompare.hpp"
42 #include "tcuRenderTarget.hpp"
43 #include "tcuSurface.hpp"
44 #include "tcuTestLog.hpp"
47 #include "glwFunctions.hpp"
51 namespace DirectStateAccess
55 /******************************** Creation Test Implementation ********************************/
57 /** @brief Creation Test constructor.
59 * @param [in] context OpenGL context.
61 CreationTest::CreationTest(deqp::Context& context)
62 : deqp::TestCase(context, "samplers_creation", "Sampler Objects Creation Test")
64 /* Intentionally left blank. */
67 /** @brief Iterate Creation Test cases.
69 * @return Iteration result.
71 tcu::TestNode::IterateResult CreationTest::iterate()
73 /* Shortcut for GL functionality */
74 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
76 /* Get context setup. */
77 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
78 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
80 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
82 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
89 bool is_error = false;
91 /* Samplers objects */
92 static const glw::GLuint samplers_count = 2;
94 glw::GLuint samplers_dsa[samplers_count] = {};
98 /* Check direct state creation. */
99 gl.createSamplers(samplers_count, samplers_dsa);
100 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateSamplers have failed");
102 for (glw::GLuint i = 0; i < samplers_count; ++i)
104 if (!gl.isSampler(samplers_dsa[i]))
109 m_context.getTestContext().getLog() << tcu::TestLog::Message
110 << "CreateSamplers has not created defualt objects."
111 << tcu::TestLog::EndMessage;
122 for (glw::GLuint i = 0; i < samplers_count; ++i)
126 gl.deleteSamplers(1, &samplers_dsa[i]);
132 /* Result's setup. */
135 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
141 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
145 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
152 /******************************** Defaults Test Implementation ********************************/
154 /** @brief Defaults Test constructor.
156 * @param [in] context OpenGL context.
158 DefaultsTest::DefaultsTest(deqp::Context& context)
159 : deqp::TestCase(context, "samplers_defaults", "Samplers Defaults Test"), m_sampler_dsa(0)
161 /* Intentionally left blank. */
164 /** @brief Iterate Defaults Test cases.
166 * @return Iteration result.
168 tcu::TestNode::IterateResult DefaultsTest::iterate()
170 /* Get context setup. */
171 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
172 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
174 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
176 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
183 bool is_error = false;
189 glw::GLfloat expected_vector[4] = { 0.0, 0.0, 0.0, 0.0 };
191 is_ok &= testSamplerFloatVectorParameter(GL_TEXTURE_BORDER_COLOR, expected_vector);
192 is_ok &= testSamplerIntegerParameter(GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
193 is_ok &= testSamplerIntegerParameter(GL_TEXTURE_COMPARE_MODE, GL_NONE);
194 is_ok &= testSamplerFloatParameter(GL_TEXTURE_LOD_BIAS, 0.0);
195 is_ok &= testSamplerFloatParameter(GL_TEXTURE_MAX_LOD, 1000);
196 is_ok &= testSamplerIntegerParameter(GL_TEXTURE_MAG_FILTER, GL_LINEAR);
197 is_ok &= testSamplerIntegerParameter(GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR);
198 is_ok &= testSamplerFloatParameter(GL_TEXTURE_MIN_LOD, -1000);
199 is_ok &= testSamplerIntegerParameter(GL_TEXTURE_WRAP_S, GL_REPEAT);
200 is_ok &= testSamplerIntegerParameter(GL_TEXTURE_WRAP_T, GL_REPEAT);
201 is_ok &= testSamplerIntegerParameter(GL_TEXTURE_WRAP_R, GL_REPEAT);
212 /* Result's setup. */
215 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
221 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
225 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
232 /** @brief Create Sampler Objects.
234 * @note The function may throw if unexpected error has occured.
236 * @return True if test succeeded, false otherwise.
238 void DefaultsTest::prepare()
240 /* Shortcut for GL functionality */
241 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
243 /* Sampler object creation */
244 gl.createSamplers(1, &m_sampler_dsa);
245 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTransformFeedbacks have failed");
248 /** @brief Test Sampler Integer Parameter.
250 * @note The function may throw if unexpected error has occured.
252 * @return True if test succeeded, false otherwise.
254 bool DefaultsTest::testSamplerIntegerParameter(glw::GLenum pname, glw::GLint expected_value)
256 /* Shortcut for GL functionality */
257 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
260 glw::GLint value = -1;
262 gl.getSamplerParameteriv(m_sampler_dsa, pname, &value);
263 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetSamplerParameteriv have failed");
267 m_context.getTestContext().getLog()
268 << tcu::TestLog::Message << "glGetSamplerParameteriv with parameter " << glu::getTextureParameterName(pname)
269 << " has not returned anything and error has not been generated." << tcu::TestLog::EndMessage;
275 if (expected_value != value)
277 m_context.getTestContext().getLog() << tcu::TestLog::Message << "glGetSamplerParameteriv with parameter "
278 << glu::getTextureParameterName(pname) << " has returned " << value
279 << ", however " << expected_value << " was expected."
280 << tcu::TestLog::EndMessage;
289 /** @brief Test Sampler Float Parameter.
291 * @note The function may throw if unexpected error has occured.
293 * @return True if test succeeded, false otherwise.
295 bool DefaultsTest::testSamplerFloatParameter(glw::GLenum pname, glw::GLfloat expected_value)
297 /* Shortcut for GL functionality */
298 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
301 glw::GLfloat value = -1.0;
303 gl.getSamplerParameterfv(m_sampler_dsa, pname, &value);
304 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetSamplerParameteriv have failed");
306 if (de::abs(expected_value - value) > 0.015625f /* Precision */)
308 m_context.getTestContext().getLog() << tcu::TestLog::Message << "glGetSamplerParameterfv with parameter "
309 << glu::getTextureParameterName(pname) << " has returned " << value
310 << ", however " << expected_value << " was expected."
311 << tcu::TestLog::EndMessage;
319 /** @brief Test Sampler Float Parameter.
321 * @note The function may throw if unexpected error has occured.
323 * @return True if test succeeded, false otherwise.
325 bool DefaultsTest::testSamplerFloatVectorParameter(glw::GLenum pname, glw::GLfloat expected_value[4])
327 /* Shortcut for GL functionality */
328 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
331 glw::GLfloat value[4] = { -1.0, -1.0, -1.0, -1.0 };
333 gl.getSamplerParameterfv(m_sampler_dsa, pname, value);
334 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetSamplerParameterfv have failed");
336 if ((de::abs(expected_value[0] - value[0]) > 0.015625f /* Precision */) ||
337 (de::abs(expected_value[1] - value[1]) > 0.015625f /* Precision */) ||
338 (de::abs(expected_value[2] - value[2]) > 0.015625f /* Precision */) ||
339 (de::abs(expected_value[3] - value[3]) > 0.015625f /* Precision */))
341 m_context.getTestContext().getLog() << tcu::TestLog::Message << "glGetSamplerParameterfv with parameter "
342 << glu::getTextureParameterName(pname) << " has returned [" << value[0]
343 << ", " << value[1] << ", " << value[2] << ", " << value[3] << "], however "
344 << expected_value << " was expected." << tcu::TestLog::EndMessage;
352 /** @brief Release GL objects.
354 void DefaultsTest::clean()
356 /* Shortcut for GL functionality */
357 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
361 gl.deleteSamplers(1, &m_sampler_dsa);
367 /******************************** Errors Test Implementation ********************************/
369 /** @brief Errors Test constructor.
371 * @param [in] context OpenGL context.
373 ErrorsTest::ErrorsTest(deqp::Context& context) : deqp::TestCase(context, "samplers_errors", "Samplers Errors Test")
375 /* Intentionally left blank. */
378 /** @brief Iterate Errors Test cases.
380 * @return Iteration result.
382 tcu::TestNode::IterateResult ErrorsTest::iterate()
384 /* Shortcut for GL functionality */
385 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
387 /* Get context setup. */
388 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
389 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
391 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
393 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
400 bool is_error = false;
402 glw::GLuint sampler_dsa = 0;
406 /* Check direct state creation. */
407 gl.createSamplers(-1, &sampler_dsa);
409 glw::GLenum error = GL_NO_ERROR;
411 if (GL_INVALID_VALUE != (error = gl.getError()))
416 m_context.getTestContext().getLog()
417 << tcu::TestLog::Message << "CreateSamplers has not generated INVALID_VALUE error when callded with "
418 "negative number of samplers to be created."
419 << "Instead, " << glu::getErrorStr(error) << " error value was generated." << tcu::TestLog::EndMessage;
431 gl.deleteSamplers(1, &sampler_dsa);
436 /* Result's setup. */
439 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
445 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
449 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
456 /******************************** Functional Test Implementation ********************************/
458 /** @brief Functional Test constructor.
460 * @param [in] context OpenGL context.
462 FunctionalTest::FunctionalTest(deqp::Context& context)
463 : deqp::TestCase(context, "samplers_functional", "Samplers Functional Test")
471 /* Intentionally left blank. */
474 /** @brief Iterate Functional Test cases.
476 * @return Iteration result.
478 tcu::TestNode::IterateResult FunctionalTest::iterate()
480 /* Get context setup. */
481 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
482 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
484 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
486 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
493 bool is_error = false;
497 prepareFramebuffer();
498 prepareVertexArrayObject();
504 is_ok &= checkFramebufferContent();
515 /* Result's setup. */
518 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
524 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
528 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
535 /** @brief Function prepares framebuffer with RGBA8 color attachment.
536 * Viewport is set up. Content of the framebuffer is cleared.
538 * @note The function may throw if unexpected error has occured.
540 void FunctionalTest::prepareFramebuffer()
542 /* Shortcut for GL functionality. */
543 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
545 /* Prepare framebuffer. */
546 gl.genFramebuffers(1, &m_fbo);
547 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
549 gl.genRenderbuffers(1, &m_rbo);
550 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
552 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
553 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
555 gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo);
556 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
558 gl.renderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 1 /* x size */, 1 /* y size */);
559 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage call failed.");
561 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo);
562 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer call failed.");
564 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
569 gl.viewport(0, 0, 1, 1);
570 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
572 /* Clear framebuffer's content. */
573 gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
574 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor call failed.");
576 gl.clear(GL_COLOR_BUFFER_BIT);
577 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear call failed.");
580 /** @brief Function generate and bind empty vertex array object.
582 * @note The function may throw if unexpected error has occured.
584 void FunctionalTest::prepareVertexArrayObject()
586 /* Shortcut for GL functionality */
587 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
589 gl.genVertexArrays(1, &m_vao);
590 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays call failed.");
592 gl.bindVertexArray(m_vao);
593 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray call failed.");
596 /** @brief Function builds test's GLSL program.
597 * If succeded, the program will be set to be used.
599 * @note The function may throw if unexpected error has occured.
601 void FunctionalTest::prepareProgram()
603 /* Shortcut for GL functionality */
604 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
608 glw::GLchar const* const source;
609 glw::GLenum const type;
611 } shader[] = { { s_vertex_shader, GL_VERTEX_SHADER, 0 }, { s_fragment_shader, GL_FRAGMENT_SHADER, 0 } };
613 glw::GLuint const shader_count = sizeof(shader) / sizeof(shader[0]);
617 /* Create program. */
618 m_po = gl.createProgram();
619 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateProgram call failed.");
621 /* Shader compilation. */
623 for (glw::GLuint i = 0; i < shader_count; ++i)
625 if (DE_NULL != shader[i].source)
627 shader[i].id = gl.createShader(shader[i].type);
629 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateShader call failed.");
631 gl.attachShader(m_po, shader[i].id);
633 GLU_EXPECT_NO_ERROR(gl.getError(), "glAttachShader call failed.");
635 gl.shaderSource(shader[i].id, 1, &(shader[i].source), NULL);
637 GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource call failed.");
639 gl.compileShader(shader[i].id);
641 GLU_EXPECT_NO_ERROR(gl.getError(), "glCompileShader call failed.");
643 glw::GLint status = GL_FALSE;
645 gl.getShaderiv(shader[i].id, GL_COMPILE_STATUS, &status);
646 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv call failed.");
648 if (GL_FALSE == status)
650 glw::GLint log_size = 0;
651 gl.getShaderiv(shader[i].id, GL_INFO_LOG_LENGTH, &log_size);
652 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv call failed.");
654 glw::GLchar* log_text = new glw::GLchar[log_size];
656 gl.getShaderInfoLog(shader[i].id, log_size, NULL, &log_text[0]);
658 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Shader compilation has failed.\n"
659 << "Shader type: " << glu::getShaderTypeStr(shader[i].type)
661 << "Shader compilation error log:\n"
663 << "Shader source code:\n"
664 << shader[i].source << "\n"
665 << tcu::TestLog::EndMessage;
669 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderInfoLog call failed.");
677 gl.linkProgram(m_po);
679 GLU_EXPECT_NO_ERROR(gl.getError(), "glTransformFeedbackVaryings call failed.");
681 glw::GLint status = GL_FALSE;
683 gl.getProgramiv(m_po, GL_LINK_STATUS, &status);
685 if (GL_TRUE == status)
687 for (glw::GLuint i = 0; i < shader_count; ++i)
691 gl.detachShader(m_po, shader[i].id);
693 GLU_EXPECT_NO_ERROR(gl.getError(), "glDetachShader call failed.");
699 glw::GLint log_size = 0;
701 gl.getProgramiv(m_po, GL_INFO_LOG_LENGTH, &log_size);
703 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramiv call failed.");
705 glw::GLchar* log_text = new glw::GLchar[log_size];
707 gl.getProgramInfoLog(m_po, log_size, NULL, &log_text[0]);
709 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Program linkage has failed due to:\n"
711 << tcu::TestLog::EndMessage;
715 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramInfoLog call failed.");
724 gl.deleteProgram(m_po);
730 for (glw::GLuint i = 0; i < shader_count; ++i)
732 if (0 != shader[i].id)
734 gl.deleteShader(shader[i].id);
743 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram call failed.");
752 /** @brief Function prepares texture object with test's data.
754 * @note The function may throw if unexpected error has occured.
756 void FunctionalTest::prepareTexture()
758 /* Shortcut for GL functionality */
759 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
761 gl.activeTexture(GL_TEXTURE0);
762 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture call failed.");
764 /* Texture creation and binding. */
765 gl.genTextures(1, &m_to);
766 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures call failed.");
768 gl.bindTexture(GL_TEXTURE_2D, m_to);
769 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture call failed.");
771 /* Uploading texture. */
773 gl.texImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, s_texture_data);
774 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D call failed.");
776 /* Setup fragment shader's sampler. */
777 glw::GLint location = 0;
779 gl.getUniformLocation(m_po, s_uniform_sampler);
780 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation call failed.");
782 gl.uniform1i(location, 0);
783 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i call failed.");
786 /** @brief Function prepares sampler with test setup and binds it to unit 0.
788 * @note The function may throw if unexpected error has occured.
790 void FunctionalTest::prepareSampler()
792 /* Shortcut for GL functionality. */
793 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
795 /* Sampler creation and setup. */
796 gl.createSamplers(1, &m_so);
797 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTransformFeedbacks have failed");
799 gl.bindSampler(0, m_so);
800 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindSampler have failed");
802 gl.samplerParameteri(m_so, GL_TEXTURE_WRAP_S, GL_REPEAT);
803 gl.samplerParameteri(m_so, GL_TEXTURE_WRAP_T, GL_REPEAT);
804 gl.samplerParameteri(m_so, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
805 gl.samplerParameteri(m_so, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
806 GLU_EXPECT_NO_ERROR(gl.getError(), "glSamplerParameteri have failed");
809 /** @brief Function draws a quad.
811 * @note The function may throw if unexpected error has occured.
813 void FunctionalTest::draw()
815 /* Shortcut for GL functionality. */
816 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
818 gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
819 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays have failed");
822 /** @brief Check content of the framebuffer and compare it with expected data.
824 * @note The function may throw if unexpected error has occured.
826 * @return True if succeeded, false otherwise.
828 bool FunctionalTest::checkFramebufferContent()
830 /* Shortcut for GL functionality. */
831 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
833 /* Fetch framebuffer data. */
834 glw::GLubyte pixel[4] = { 0 };
836 gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
837 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels have failed");
839 /* Comparison with expected values. */
840 if ((s_texture_data[0] != pixel[0]) || (s_texture_data[1] != pixel[1]) || (s_texture_data[2] != pixel[2]) ||
841 (s_texture_data[3] != pixel[3]))
843 m_context.getTestContext().getLog()
844 << tcu::TestLog::Message << "Frameuffer content (" << (unsigned int)pixel[0] << ", "
845 << (unsigned int)pixel[1] << ", " << (unsigned int)pixel[2] << ", " << (unsigned int)pixel[3]
846 << ") is different than expected (" << (unsigned int)s_texture_data[0] << ", "
847 << (unsigned int)s_texture_data[1] << ", " << (unsigned int)s_texture_data[2] << ", "
848 << (unsigned int)s_texture_data[3] << ")." << tcu::TestLog::EndMessage;
856 /** @brief Release all GL objects.
858 void FunctionalTest::clean()
860 /* Shortcut for GL functionality. */
861 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
863 /* Release framebuffer. */
866 gl.deleteFramebuffers(1, &m_fbo);
871 /* Release renderbuffer. */
874 gl.deleteRenderbuffers(1, &m_rbo);
879 /* Release vertex array object. */
882 gl.deleteVertexArrays(1, &m_vao);
887 /* Release texture. */
890 gl.deleteTextures(1, &m_to);
895 /* Release sampler. */
898 gl.deleteSamplers(1, &m_so);
903 /* Release GLSL program. */
908 gl.deleteProgram(m_po);
914 /* Vertex shader source code. */
915 const glw::GLchar FunctionalTest::s_vertex_shader[] = "#version 330\n"
919 " switch(gl_VertexID)\n"
922 " gl_Position = vec4(-1.0, 1.0, 0.0, 1.0);\n"
925 " gl_Position = vec4( 1.0, 1.0, 0.0, 1.0);\n"
928 " gl_Position = vec4(-1.0,-1.0, 0.0, 1.0);\n"
931 " gl_Position = vec4( 1.0,-1.0, 0.0, 1.0);\n"
936 /* Fragment shader source program. */
937 const glw::GLchar FunctionalTest::s_fragment_shader[] =
940 "uniform sampler2D texture_sampler;\n"
946 " color = texture(texture_sampler, vec2(0.33333, 0.33333));\n"
949 /* Name of texture sampler uniform. */
950 const glw::GLchar FunctionalTest::s_uniform_sampler[] = "texture_sampler";
952 /* Test's texture data. */
953 const glw::GLubyte FunctionalTest::s_texture_data[] = {
954 0xFF, 0x00, 0x00, 0xFF, /* RED */
955 0x00, 0xFF, 0x00, 0xFF, /* GREEN */
956 0x00, 0x00, 0xFF, 0xFF, /* BLUE */
957 0xFF, 0xFF, 0x00, 0xFF /* YELLOW */
960 } /* Samplers namespace. */
961 } /* DirectStateAccess namespace. */
962 } /* gl4cts namespace. */