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 gl4cDirectStateAccessTexturesTests.cpp
27 * \brief Conformance tests for the Direct State Access feature functionality (Texture access part).
28 */ /*-----------------------------------------------------------------------------------------------------------*/
30 /* Uncomment this if SubImageErrorsTest crashes during negative test of TextureSubImage (negative value width/height/depth passed to the function). */
31 /* #define TURN_OFF_SUB_IMAGE_ERRORS_TEST_OF_NEGATIVE_WIDTH_HEIGHT_OR_DEPTH */
34 #include "gl4cDirectStateAccessTests.hpp"
36 #include "deSharedPtr.hpp"
38 #include "gluContextInfo.hpp"
39 #include "gluDefs.hpp"
40 #include "gluPixelTransfer.hpp"
41 #include "gluStrUtil.hpp"
43 #include "tcuFuzzyImageCompare.hpp"
44 #include "tcuImageCompare.hpp"
45 #include "tcuRenderTarget.hpp"
46 #include "tcuSurface.hpp"
47 #include "tcuTestLog.hpp"
50 #include "glwFunctions.hpp"
61 namespace DirectStateAccess
65 /******************************** Creation Test Implementation ********************************/
67 /** @brief Creation Test constructor.
69 * @param [in] context OpenGL context.
71 CreationTest::CreationTest(deqp::Context& context)
72 : deqp::TestCase(context, "textures_creation", "Texture Objects Creation Test")
74 /* Intentionally left blank. */
77 /** @brief Iterate Creation Test cases.
79 * @return Iteration result.
81 tcu::TestNode::IterateResult CreationTest::iterate()
83 /* Shortcut for GL functionality. */
84 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
86 /* Get context setup. */
87 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
88 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
90 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
92 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
99 bool is_error = false;
101 /* Textures' objects */
102 static const glw::GLenum texture_targets[] = { GL_TEXTURE_1D,
107 GL_TEXTURE_RECTANGLE,
109 GL_TEXTURE_CUBE_MAP_ARRAY,
111 GL_TEXTURE_2D_MULTISAMPLE,
112 GL_TEXTURE_2D_MULTISAMPLE_ARRAY };
113 static const glw::GLuint texture_targets_count = sizeof(texture_targets) / sizeof(texture_targets[0]);
114 static const glw::GLuint textures_count = 2;
116 glw::GLuint textures_legacy[textures_count] = {};
117 glw::GLuint textures_dsa[texture_targets_count][textures_count] = {};
121 /* Check legacy state creation. */
122 gl.genTextures(textures_count, textures_legacy);
123 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
125 for (glw::GLuint i = 0; i < textures_count; ++i)
127 if (gl.isTexture(textures_legacy[i]))
132 m_context.getTestContext().getLog()
133 << tcu::TestLog::Message
134 << "GenTextures has created default objects, but it should create only a names."
135 << tcu::TestLog::EndMessage;
139 /* Check direct state creation. */
140 for (glw::GLuint j = 0; j < texture_targets_count; ++j)
142 gl.createTextures(texture_targets[j], textures_count, textures_dsa[j]);
143 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
145 for (glw::GLuint i = 0; i < textures_count; ++i)
147 if (!gl.isTexture(textures_dsa[j][i]))
152 m_context.getTestContext().getLog()
153 << tcu::TestLog::Message << "CreateTextures has not created default objects for target "
154 << glu::getTextureTargetStr(texture_targets[j]) << "." << tcu::TestLog::EndMessage;
166 for (glw::GLuint i = 0; i < textures_count; ++i)
168 if (textures_legacy[i])
170 gl.deleteTextures(1, &textures_legacy[i]);
172 textures_legacy[i] = 0;
175 for (glw::GLuint j = 0; j < texture_targets_count; ++j)
177 if (textures_dsa[j][i])
179 gl.deleteTextures(1, &textures_dsa[j][i]);
181 textures_dsa[j][i] = 0;
186 /* Errors clean up. */
187 while (gl.getError())
190 /* Result's setup. */
193 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
199 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
203 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
210 /******************************** Reference Data Implementation *****************************/
212 /** @brief Internal Format selector.
215 * @tparam S Size (# of components).
216 * @tparam N Is normalized.
218 * @return Internal format.
221 glw::GLenum Reference::InternalFormat<glw::GLbyte, 1, false>()
227 glw::GLenum Reference::InternalFormat<glw::GLbyte, 2, false>()
233 glw::GLenum Reference::InternalFormat<glw::GLbyte, 3, false>()
239 glw::GLenum Reference::InternalFormat<glw::GLbyte, 4, false>()
245 glw::GLenum Reference::InternalFormat<glw::GLubyte, 1, false>()
251 glw::GLenum Reference::InternalFormat<glw::GLubyte, 2, false>()
257 glw::GLenum Reference::InternalFormat<glw::GLubyte, 3, false>()
263 glw::GLenum Reference::InternalFormat<glw::GLubyte, 4, false>()
269 glw::GLenum Reference::InternalFormat<glw::GLshort, 1, false>()
275 glw::GLenum Reference::InternalFormat<glw::GLshort, 2, false>()
281 glw::GLenum Reference::InternalFormat<glw::GLshort, 3, false>()
287 glw::GLenum Reference::InternalFormat<glw::GLshort, 4, false>()
293 glw::GLenum Reference::InternalFormat<glw::GLushort, 1, false>()
299 glw::GLenum Reference::InternalFormat<glw::GLushort, 2, false>()
305 glw::GLenum Reference::InternalFormat<glw::GLushort, 3, false>()
311 glw::GLenum Reference::InternalFormat<glw::GLushort, 4, false>()
317 glw::GLenum Reference::InternalFormat<glw::GLint, 1, false>()
323 glw::GLenum Reference::InternalFormat<glw::GLint, 2, false>()
329 glw::GLenum Reference::InternalFormat<glw::GLint, 3, false>()
335 glw::GLenum Reference::InternalFormat<glw::GLint, 4, false>()
341 glw::GLenum Reference::InternalFormat<glw::GLuint, 1, false>()
347 glw::GLenum Reference::InternalFormat<glw::GLuint, 2, false>()
353 glw::GLenum Reference::InternalFormat<glw::GLuint, 3, false>()
359 glw::GLenum Reference::InternalFormat<glw::GLuint, 4, false>()
365 glw::GLenum Reference::InternalFormat<glw::GLubyte, 1, true>()
371 glw::GLenum Reference::InternalFormat<glw::GLubyte, 2, true>()
377 glw::GLenum Reference::InternalFormat<glw::GLubyte, 3, true>()
383 glw::GLenum Reference::InternalFormat<glw::GLubyte, 4, true>()
389 glw::GLenum Reference::InternalFormat<glw::GLushort, 1, true>()
395 glw::GLenum Reference::InternalFormat<glw::GLushort, 2, true>()
401 glw::GLenum Reference::InternalFormat<glw::GLushort, 3, true>()
407 glw::GLenum Reference::InternalFormat<glw::GLushort, 4, true>()
413 glw::GLenum Reference::InternalFormat<glw::GLfloat, 1, true>()
419 glw::GLenum Reference::InternalFormat<glw::GLfloat, 2, true>()
425 glw::GLenum Reference::InternalFormat<glw::GLfloat, 3, true>()
431 glw::GLenum Reference::InternalFormat<glw::GLfloat, 4, true>()
436 /** @brief Format selector.
438 * @tparam S Size (# of components).
439 * @tparam N Is normalized.
444 glw::GLenum Reference::Format<1, false>()
446 return GL_RED_INTEGER;
450 glw::GLenum Reference::Format<2, false>()
452 return GL_RG_INTEGER;
456 glw::GLenum Reference::Format<3, false>()
458 return GL_RGB_INTEGER;
462 glw::GLenum Reference::Format<4, false>()
464 return GL_RGBA_INTEGER;
468 glw::GLenum Reference::Format<1, true>()
474 glw::GLenum Reference::Format<2, true>()
480 glw::GLenum Reference::Format<3, true>()
486 glw::GLenum Reference::Format<4, true>()
491 /** @brief Type selector.
498 glw::GLenum Reference::Type<glw::GLbyte>()
504 glw::GLenum Reference::Type<glw::GLubyte>()
506 return GL_UNSIGNED_BYTE;
510 glw::GLenum Reference::Type<glw::GLshort>()
516 glw::GLenum Reference::Type<glw::GLushort>()
518 return GL_UNSIGNED_SHORT;
522 glw::GLenum Reference::Type<glw::GLint>()
528 glw::GLenum Reference::Type<glw::GLuint>()
530 return GL_UNSIGNED_INT;
534 glw::GLenum Reference::Type<glw::GLfloat>()
539 /** @brief Reference data selector.
542 * @tparam N Is normalized.
544 * @return Reference data.
549 const glw::GLbyte* Reference::ReferenceData<glw::GLbyte, false>()
551 static const glw::GLbyte reference[s_reference_count] = {
552 0, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, -21, 22, -23,
553 24, -25, 26, -27, 28, -29, 30, -31, 32, -33, 34, -35, 36, -37, 38, -39, 40, -41, 42, -43, 44, -45, 46, -47,
554 48, -49, 50, -51, 52, -53, 54, -55, 56, -57, 58, -59, 60, -61, 62, -63, 64, -65, 66, -67, 68, -69, 70, -71,
555 72, -73, 74, -75, 76, -77, 78, -79, 80, -81, 82, -83, 84, -85, 86, -87, 88, -89, 90, -91, 92, -93, 94, -95
562 const glw::GLubyte* Reference::ReferenceData<glw::GLubyte, false>()
564 static const glw::GLubyte reference[s_reference_count] = {
565 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
566 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
567 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
568 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95
575 const glw::GLshort* Reference::ReferenceData<glw::GLshort, false>()
577 static const glw::GLshort reference[s_reference_count] = {
578 0, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, -21, 22, -23,
579 24, -25, 26, -27, 28, -29, 30, -31, 32, -33, 34, -35, 36, -37, 38, -39, 40, -41, 42, -43, 44, -45, 46, -47,
580 48, -49, 50, -51, 52, -53, 54, -55, 56, -57, 58, -59, 60, -61, 62, -63, 64, -65, 66, -67, 68, -69, 70, -71,
581 72, -73, 74, -75, 76, -77, 78, -79, 80, -81, 82, -83, 84, -85, 86, -87, 88, -89, 90, -91, 92, -93, 94, -95
588 const glw::GLushort* Reference::ReferenceData<glw::GLushort, false>()
590 static const glw::GLushort reference[s_reference_count] = {
591 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
592 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
593 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
594 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95
601 const glw::GLint* Reference::ReferenceData<glw::GLint, false>()
603 static const glw::GLint reference[s_reference_count] = {
604 0, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, -21, 22, -23,
605 24, -25, 26, -27, 28, -29, 30, -31, 32, -33, 34, -35, 36, -37, 38, -39, 40, -41, 42, -43, 44, -45, 46, -47,
606 48, -49, 50, -51, 52, -53, 54, -55, 56, -57, 58, -59, 60, -61, 62, -63, 64, -65, 66, -67, 68, -69, 70, -71,
607 72, -73, 74, -75, 76, -77, 78, -79, 80, -81, 82, -83, 84, -85, 86, -87, 88, -89, 90, -91, 92, -93, 94, -95
614 const glw::GLuint* Reference::ReferenceData<glw::GLuint, false>()
616 static const glw::GLuint reference[s_reference_count] = {
617 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
618 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
619 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
620 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95
627 const glw::GLubyte* Reference::ReferenceData<glw::GLubyte, true>()
629 static const glw::GLubyte reference[s_reference_count] = {
630 0, 2, 5, 8, 10, 13, 16, 18, 21, 24, 26, 29, 32, 34, 37, 40, 42, 45, 48, 51,
631 53, 56, 59, 61, 64, 67, 69, 72, 75, 77, 80, 83, 85, 88, 91, 93, 96, 99, 102, 104,
632 107, 110, 112, 115, 118, 120, 123, 126, 128, 131, 134, 136, 139, 142, 144, 147, 150, 153, 155, 158,
633 161, 163, 166, 169, 171, 174, 177, 179, 182, 185, 187, 190, 193, 195, 198, 201, 204, 206, 209, 212,
634 214, 217, 220, 222, 225, 228, 230, 233, 236, 238, 241, 244, 246, 249, 252, 255
641 const glw::GLushort* Reference::ReferenceData<glw::GLushort, true>()
643 static const glw::GLushort reference[s_reference_count] = {
644 0, 689, 1379, 2069, 2759, 3449, 4139, 4828, 5518, 6208, 6898, 7588, 8278, 8967, 9657, 10347,
645 11037, 11727, 12417, 13107, 13796, 14486, 15176, 15866, 16556, 17246, 17935, 18625, 19315, 20005, 20695, 21385,
646 22074, 22764, 23454, 24144, 24834, 25524, 26214, 26903, 27593, 28283, 28973, 29663, 30353, 31042, 31732, 32422,
647 33112, 33802, 34492, 35181, 35871, 36561, 37251, 37941, 38631, 39321, 40010, 40700, 41390, 42080, 42770, 43460,
648 44149, 44839, 45529, 46219, 46909, 47599, 48288, 48978, 49668, 50358, 51048, 51738, 52428, 53117, 53807, 54497,
649 55187, 55877, 56567, 57256, 57946, 58636, 59326, 60016, 60706, 61395, 62085, 62775, 63465, 64155, 64845, 65535
656 const glw::GLfloat* Reference::ReferenceData<glw::GLfloat, true>()
658 static const glw::GLfloat reference[s_reference_count] = {
659 0.f, 0.0105263158f, 0.0210526316f, 0.0315789474f, 0.0421052632f, 0.0526315789f,
660 0.0631578947f, 0.0736842105f, 0.0842105263f, 0.0947368421f, 0.1052631579f, 0.1157894737f,
661 0.1263157895f, 0.1368421053f, 0.1473684211f, 0.1578947368f, 0.1684210526f, 0.1789473684f,
662 0.1894736842f, 0.2f, 0.2105263158f, 0.2210526316f, 0.2315789474f, 0.2421052632f,
663 0.2526315789f, 0.2631578947f, 0.2736842105f, 0.2842105263f, 0.2947368421f, 0.3052631579f,
664 0.3157894737f, 0.3263157895f, 0.3368421053f, 0.3473684211f, 0.3578947368f, 0.3684210526f,
665 0.3789473684f, 0.3894736842f, 0.4f, 0.4105263158f, 0.4210526316f, 0.4315789474f,
666 0.4421052632f, 0.4526315789f, 0.4631578947f, 0.4736842105f, 0.4842105263f, 0.4947368421f,
667 0.5052631579f, 0.5157894737f, 0.5263157895f, 0.5368421053f, 0.5473684211f, 0.5578947368f,
668 0.5684210526f, 0.5789473684f, 0.5894736842f, 0.6f, 0.6105263158f, 0.6210526316f,
669 0.6315789474f, 0.6421052632f, 0.6526315789f, 0.6631578947f, 0.6736842105f, 0.6842105263f,
670 0.6947368421f, 0.7052631579f, 0.7157894737f, 0.7263157895f, 0.7368421053f, 0.7473684211f,
671 0.7578947368f, 0.7684210526f, 0.7789473684f, 0.7894736842f, 0.8f, 0.8105263158f,
672 0.8210526316f, 0.8315789474f, 0.8421052632f, 0.8526315789f, 0.8631578947f, 0.8736842105f,
673 0.8842105263f, 0.8947368421f, 0.9052631579f, 0.9157894737f, 0.9263157895f, 0.9368421053f,
674 0.9473684211f, 0.9578947368f, 0.9684210526f, 0.9789473684f, 0.9894736842f, 1.f
679 /* Total number of reference components. */
680 glw::GLuint Reference::ReferenceDataCount()
682 return s_reference_count;
685 /* Total number of reference size in basic machine units. */
686 template <typename T>
687 glw::GLuint Reference::ReferenceDataSize()
689 return Reference::ReferenceDataCount() * sizeof(T);
692 /** @brief Comparison function (for floats).
694 * @param [in] a First element.
695 * @param [in] b Second element.
697 * @return Comparison result.
700 bool Reference::Compare<glw::GLfloat>(const glw::GLfloat a, const glw::GLfloat b)
702 if (de::abs(a - b) < 1.f / 256.f)
709 /** @brief Comparison function (integer).
711 * @param [in] a First element.
712 * @param [in] b Second element.
714 * @return Comparison result.
716 template <typename T>
717 bool Reference::Compare(const T a, const T b)
722 /******************************** Buffer Test Implementation ********************************/
724 /** @brief Buffer Test constructor.
728 * @tparam N Is normalized.
730 * @param [in] context OpenGL context.
731 * @param [in] name Name of the test.
733 template <typename T, glw::GLint S, bool N>
734 BufferTest<T, S, N>::BufferTest(deqp::Context& context, const char* name)
735 : deqp::TestCase(context, name, "Texture Buffer Objects Test")
743 /* Intentionally left blank. */
746 /** @brief Count of reference data to be teted.
750 template <typename T, glw::GLint S, bool N>
751 glw::GLuint BufferTest<T, S, N>::TestReferenceDataCount()
753 return s_fbo_size_x * S;
756 /** @brief Size of reference data to be teted..
760 template <typename T, glw::GLint S, bool N>
761 glw::GLuint BufferTest<T, S, N>::TestReferenceDataSize()
763 return static_cast<glw::GLint>(TestReferenceDataCount() * sizeof(T));
766 /** @brief Create buffer textuew.
768 * @param [in] use_range_version Uses TextureBufferRange instead TextureBuffer.
770 * @return True if succeded, false otherwise.
772 template <typename T, glw::GLint S, bool N>
773 bool BufferTest<T, S, N>::CreateBufferTexture(bool use_range_version)
775 /* Shortcut for GL functionality. */
776 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
778 /* Objects creation. */
779 gl.genTextures(1, &m_to);
780 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
782 gl.bindTexture(GL_TEXTURE_BUFFER, m_to);
783 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
785 gl.genBuffers(1, &m_bo);
786 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateBuffers has failed");
788 gl.bindBuffer(GL_TEXTURE_BUFFER, m_bo);
789 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
792 if (use_range_version)
794 glw::GLint alignment = 1;
796 gl.getIntegerv(GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT, &alignment);
797 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
799 const glw::GLuint b_offset = alignment;
800 const glw::GLuint b_size = TestReferenceDataSize() + b_offset;
802 gl.bufferData(GL_TEXTURE_BUFFER, b_size, NULL, GL_STATIC_DRAW);
803 GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData has failed");
805 gl.bufferSubData(GL_TEXTURE_BUFFER, b_offset, TestReferenceDataSize(), ReferenceData<T, N>());
806 GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferSubdata has failed");
808 gl.textureBufferRange(m_to, InternalFormat<T, S, N>(), m_bo, b_offset, TestReferenceDataSize());
812 gl.bufferData(GL_TEXTURE_BUFFER, TestReferenceDataSize(), ReferenceData<T, N>(), GL_STATIC_DRAW);
813 GLU_EXPECT_NO_ERROR(gl.getError(), "glNamedBufferData has failed");
815 gl.textureBuffer(m_to, InternalFormat<T, S, N>(), m_bo);
818 /* Error checking. */
821 if (GL_NO_ERROR != (error = gl.getError()))
824 m_context.getTestContext().getLog()
825 << tcu::TestLog::Message << (use_range_version ? ("glTextureBufferRange") : ("glTextureBuffer"))
826 << " unexpectedly generated error " << glu::getErrorStr(error) << " during test of internal format "
827 << glu::getTextureFormatStr(InternalFormat<T, S, N>()) << "." << tcu::TestLog::EndMessage;
829 CleanBufferTexture();
837 /** @brief Function prepares framebuffer with internal format color attachment.
838 * Viewport is set up. Content of the framebuffer is cleared.
840 * @note The function may throw if unexpected error has occured.
842 * @return if the framebuffer returned is supported
844 template <typename T, glw::GLint S, bool N>
845 bool BufferTest<T, S, N>::PrepareFramebuffer(const glw::GLenum internal_format)
847 /* Shortcut for GL functionality. */
848 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
850 /* Prepare framebuffer. */
851 gl.genFramebuffers(1, &m_fbo);
852 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
854 gl.genRenderbuffers(1, &m_rbo);
855 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
857 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
858 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
860 gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo);
861 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
863 gl.renderbufferStorage(GL_RENDERBUFFER, internal_format, s_fbo_size_x, s_fbo_size_y);
864 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage call failed.");
866 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo);
867 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer call failed.");
869 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
871 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_UNSUPPORTED)
872 throw tcu::NotSupportedError("unsupported framebuffer configuration");
877 gl.viewport(0, 0, s_fbo_size_x, s_fbo_size_y);
878 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
880 /* Clear framebuffer's content. */
881 gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
882 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor call failed.");
884 gl.clear(GL_COLOR_BUFFER_BIT);
885 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear call failed.");
890 /** @brief Create program.
892 * @param [in] variable_declaration Choose variable declaration of the fragment shader.
894 template <typename T, glw::GLint S, bool N>
895 void BufferTest<T, S, N>::PrepareProgram(const glw::GLchar* variable_declaration)
897 /* Shortcut for GL functionality */
898 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
902 glw::GLchar const* source[3];
903 glw::GLsizei const count;
904 glw::GLenum const type;
907 { { s_vertex_shader, NULL, NULL }, 1, GL_VERTEX_SHADER, 0 },
908 { { s_fragment_shader_head, variable_declaration, s_fragment_shader_tail }, 3, GL_FRAGMENT_SHADER, 0 }
911 glw::GLuint const shader_count = sizeof(shader) / sizeof(shader[0]);
915 /* Create program. */
916 m_po = gl.createProgram();
917 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateProgram call failed.");
919 /* Shader compilation. */
921 for (glw::GLuint i = 0; i < shader_count; ++i)
924 shader[i].id = gl.createShader(shader[i].type);
926 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateShader call failed.");
928 gl.attachShader(m_po, shader[i].id);
930 GLU_EXPECT_NO_ERROR(gl.getError(), "glAttachShader call failed.");
932 gl.shaderSource(shader[i].id, shader[i].count, shader[i].source, NULL);
934 GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource call failed.");
936 gl.compileShader(shader[i].id);
938 GLU_EXPECT_NO_ERROR(gl.getError(), "glCompileShader call failed.");
940 glw::GLint status = GL_FALSE;
942 gl.getShaderiv(shader[i].id, GL_COMPILE_STATUS, &status);
943 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv call failed.");
945 if (GL_FALSE == status)
947 glw::GLint log_size = 0;
948 gl.getShaderiv(shader[i].id, GL_INFO_LOG_LENGTH, &log_size);
949 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv call failed.");
951 glw::GLchar* log_text = new glw::GLchar[log_size];
953 gl.getShaderInfoLog(shader[i].id, log_size, NULL, &log_text[0]);
955 m_context.getTestContext().getLog()
956 << tcu::TestLog::Message << "Shader compilation has failed.\n"
957 << "Shader type: " << glu::getShaderTypeStr(shader[i].type) << "\n"
958 << "Shader compilation error log:\n"
960 << "Shader source code:\n"
961 << shader[i].source[0] << (shader[i].source[1] ? shader[i].source[1] : "")
962 << (shader[i].source[2] ? shader[i].source[2] : "") << "\n"
963 << tcu::TestLog::EndMessage;
967 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderInfoLog call failed.");
975 gl.linkProgram(m_po);
977 GLU_EXPECT_NO_ERROR(gl.getError(), "glTransformFeedbackVaryings call failed.");
979 glw::GLint status = GL_FALSE;
981 gl.getProgramiv(m_po, GL_LINK_STATUS, &status);
983 if (GL_TRUE == status)
985 for (glw::GLuint i = 0; i < shader_count; ++i)
989 gl.detachShader(m_po, shader[i].id);
991 GLU_EXPECT_NO_ERROR(gl.getError(), "glDetachShader call failed.");
997 glw::GLint log_size = 0;
999 gl.getProgramiv(m_po, GL_INFO_LOG_LENGTH, &log_size);
1001 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramiv call failed.");
1003 glw::GLchar* log_text = new glw::GLchar[log_size];
1005 gl.getProgramInfoLog(m_po, log_size, NULL, &log_text[0]);
1007 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Program linkage has failed due to:\n"
1009 << tcu::TestLog::EndMessage;
1013 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramInfoLog call failed.");
1022 gl.deleteProgram(m_po);
1028 for (glw::GLuint i = 0; i < shader_count; ++i)
1030 if (0 != shader[i].id)
1032 gl.deleteShader(shader[i].id);
1044 /** @brief Create VAO.
1046 template <typename T, glw::GLint S, bool N>
1047 void BufferTest<T, S, N>::PrepareVertexArray()
1049 /* Shortcut for GL functionality. */
1050 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1052 gl.genVertexArrays(1, &m_vao);
1053 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays has failed");
1055 gl.bindVertexArray(m_vao);
1056 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray has failed");
1059 /** @brief Test's draw function.
1061 template <typename T, glw::GLint S, bool N>
1062 void BufferTest<T, S, N>::Draw()
1064 /* Shortcut for GL functionality. */
1065 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1067 gl.useProgram(m_po);
1068 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram has failed");
1070 gl.activeTexture(GL_TEXTURE0);
1071 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
1073 gl.bindTextureUnit(0, m_to);
1074 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
1076 gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
1077 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays has failed");
1080 /** @brief Compre results with the reference.
1082 * @return True if equal, false otherwise.
1084 template <typename T, glw::GLint S, bool N>
1085 bool BufferTest<T, S, N>::Check()
1087 /* Shortcut for GL functionality. */
1088 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1090 /* Fetching data. */
1091 std::vector<T> result(TestReferenceDataCount());
1093 gl.pixelStorei(GL_UNPACK_ALIGNMENT, sizeof(T));
1094 GLU_EXPECT_NO_ERROR(gl.getError(), "glPixelStorei has failed");
1096 gl.pixelStorei(GL_PACK_ALIGNMENT, sizeof(T));
1097 GLU_EXPECT_NO_ERROR(gl.getError(), "glPixelStorei has failed");
1099 gl.readnPixels(0, 0, s_fbo_size_x, s_fbo_size_y, Format<S, N>(), Type<T>(), TestReferenceDataSize(),
1100 (glw::GLvoid*)(&result[0]));
1101 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels has failed");
1106 for (glw::GLuint i = 0; i < TestReferenceDataCount(); ++i)
1108 if (!Compare<T>(result[i], ReferenceData<T, N>()[i]))
1119 /** @brief Test function.
1121 * @param [in] use_range_version Uses TextureBufferRange instead TextureBuffer.
1123 * @return True if succeeded, false otherwise.
1125 template <typename T, glw::GLint S, bool N>
1126 bool BufferTest<T, S, N>::Test(bool use_range_version)
1129 if (!PrepareFramebuffer(InternalFormat<T, S, N>()))
1132 * If the framebuffer it not supported, means that the
1133 * tested combination is unsupported for this driver,
1134 * but allowed to be unsupported by OpenGL spec, so we
1143 if (!CreateBufferTexture(use_range_version))
1154 /* Compare results with reference. */
1155 bool result = Check();
1159 CleanBufferTexture();
1166 /** @brief Clean GL objects
1168 template <typename T, glw::GLint S, bool N>
1169 void BufferTest<T, S, N>::CleanBufferTexture()
1171 /* Shortcut for GL functionality. */
1172 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1177 gl.deleteTextures(1, &m_to);
1182 /* Texture buffer. */
1185 gl.deleteBuffers(1, &m_bo);
1191 /** @brief Clean GL objects
1193 template <typename T, glw::GLint S, bool N>
1194 void BufferTest<T, S, N>::CleanFramebuffer()
1196 /* Shortcut for GL functionality. */
1197 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1202 gl.deleteFramebuffers(1, &m_fbo);
1210 gl.deleteRenderbuffers(1, &m_rbo);
1216 /** @brief Clean GL objects
1218 template <typename T, glw::GLint S, bool N>
1219 void BufferTest<T, S, N>::CleanProgram()
1221 /* Shortcut for GL functionality. */
1222 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1229 gl.deleteProgram(m_po);
1235 /** @brief Clean errors.
1237 template <typename T, glw::GLint S, bool N>
1238 void BufferTest<T, S, N>::CleanErrors()
1240 /* Shortcut for GL functionality. */
1241 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1243 /* Query all errors until GL_NO_ERROR occure. */
1244 while (GL_NO_ERROR != gl.getError())
1248 /** @brief Clean GL objects
1250 template <typename T, glw::GLint S, bool N>
1251 void BufferTest<T, S, N>::CleanVertexArray()
1253 /* Shortcut for GL functionality. */
1254 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1258 gl.bindVertexArray(0);
1260 gl.deleteVertexArrays(1, &m_vao);
1266 /** @brief Iterate Buffer Test cases.
1268 * @return Iteration result.
1270 template <typename T, glw::GLint S, bool N>
1271 tcu::TestNode::IterateResult BufferTest<T, S, N>::iterate()
1273 /* Shortcut for GL functionality. */
1274 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1276 /* Get context setup. */
1277 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
1278 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
1280 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
1282 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
1287 /* Running tests. */
1289 bool is_error = false;
1293 PrepareVertexArray();
1295 PrepareProgram(FragmentShaderDeclaration());
1297 for (glw::GLuint i = 0; i < 2; ++i)
1299 bool use_range = (i == 1);
1300 is_ok &= Test(use_range);
1306 catch (tcu::NotSupportedError e)
1317 CleanBufferTexture();
1323 /* Errors clean up. */
1324 while (gl.getError())
1327 /* Result's setup. */
1330 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1336 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
1340 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
1347 /* Vertex shader source code. */
1348 template <typename T, glw::GLint S, bool N>
1349 const glw::GLchar* BufferTest<T, S, N>::s_vertex_shader = "#version 450\n"
1353 " switch(gl_VertexID)\n"
1356 " gl_Position = vec4(-1.0, 1.0, 0.0, 1.0);\n"
1359 " gl_Position = vec4( 1.0, 1.0, 0.0, 1.0);\n"
1362 " gl_Position = vec4(-1.0,-1.0, 0.0, 1.0);\n"
1365 " gl_Position = vec4( 1.0,-1.0, 0.0, 1.0);\n"
1370 /* Fragment shader source program. */
1371 template <typename T, glw::GLint S, bool N>
1372 const glw::GLchar* BufferTest<T, S, N>::s_fragment_shader_head = "#version 450\n"
1374 "layout(pixel_center_integer) in vec4 gl_FragCoord;\n"
1377 template <typename T, glw::GLint S, bool N>
1378 const glw::GLchar* BufferTest<T, S, N>::s_fragment_shader_fdecl_lowp = "uniform samplerBuffer texture_input;\n"
1379 "out vec4 texture_output;\n";
1381 template <typename T, glw::GLint S, bool N>
1382 const glw::GLchar* BufferTest<T, S, N>::s_fragment_shader_idecl_lowp = "uniform isamplerBuffer texture_input;\n"
1383 "out ivec4 texture_output;\n";
1385 template <typename T, glw::GLint S, bool N>
1386 const glw::GLchar* BufferTest<T, S, N>::s_fragment_shader_udecl_lowp = "uniform usamplerBuffer texture_input;\n"
1387 "out uvec4 texture_output;\n";
1389 template <typename T, glw::GLint S, bool N>
1390 const glw::GLchar* BufferTest<T, S, N>::s_fragment_shader_fdecl_mediump = "uniform samplerBuffer texture_input;\n"
1391 "out vec4 texture_output;\n";
1393 template <typename T, glw::GLint S, bool N>
1394 const glw::GLchar* BufferTest<T, S, N>::s_fragment_shader_idecl_mediump = "uniform isamplerBuffer texture_input;\n"
1395 "out ivec4 texture_output;\n";
1397 template <typename T, glw::GLint S, bool N>
1398 const glw::GLchar* BufferTest<T, S, N>::s_fragment_shader_udecl_mediump = "uniform usamplerBuffer texture_input;\n"
1399 "out uvec4 texture_output;\n";
1401 template <typename T, glw::GLint S, bool N>
1402 const glw::GLchar* BufferTest<T, S, N>::s_fragment_shader_fdecl_highp = "uniform samplerBuffer texture_input;\n"
1403 "out vec4 texture_output;\n";
1405 template <typename T, glw::GLint S, bool N>
1406 const glw::GLchar* BufferTest<T, S, N>::s_fragment_shader_idecl_highp = "uniform isamplerBuffer texture_input;\n"
1407 "out ivec4 texture_output;\n";
1409 template <typename T, glw::GLint S, bool N>
1410 const glw::GLchar* BufferTest<T, S, N>::s_fragment_shader_udecl_highp = "uniform usamplerBuffer texture_input;\n"
1411 "out uvec4 texture_output;\n";
1413 template <typename T, glw::GLint S, bool N>
1414 const glw::GLchar* BufferTest<T, S, N>::s_fragment_shader_tail =
1418 " texture_output = texelFetch(texture_input, int(gl_FragCoord.x));\n"
1421 template class BufferTest<glw::GLbyte, 1, false>;
1422 template class BufferTest<glw::GLbyte, 2, false>;
1423 template class BufferTest<glw::GLbyte, 4, false>;
1425 template class BufferTest<glw::GLubyte, 1, false>;
1426 template class BufferTest<glw::GLubyte, 2, false>;
1427 template class BufferTest<glw::GLubyte, 4, false>;
1428 template class BufferTest<glw::GLubyte, 1, true>;
1429 template class BufferTest<glw::GLubyte, 2, true>;
1430 template class BufferTest<glw::GLubyte, 4, true>;
1432 template class BufferTest<glw::GLshort, 1, false>;
1433 template class BufferTest<glw::GLshort, 2, false>;
1434 template class BufferTest<glw::GLshort, 4, false>;
1436 template class BufferTest<glw::GLushort, 1, false>;
1437 template class BufferTest<glw::GLushort, 2, false>;
1438 template class BufferTest<glw::GLushort, 4, false>;
1439 template class BufferTest<glw::GLushort, 1, true>;
1440 template class BufferTest<glw::GLushort, 2, true>;
1441 template class BufferTest<glw::GLushort, 4, true>;
1443 template class BufferTest<glw::GLint, 1, false>;
1444 template class BufferTest<glw::GLint, 2, false>;
1445 template class BufferTest<glw::GLint, 3, false>;
1446 template class BufferTest<glw::GLint, 4, false>;
1448 template class BufferTest<glw::GLuint, 1, false>;
1449 template class BufferTest<glw::GLuint, 2, false>;
1450 template class BufferTest<glw::GLuint, 3, false>;
1451 template class BufferTest<glw::GLuint, 4, false>;
1453 template class BufferTest<glw::GLfloat, 1, true>;
1454 template class BufferTest<glw::GLfloat, 2, true>;
1455 template class BufferTest<glw::GLfloat, 3, true>;
1456 template class BufferTest<glw::GLfloat, 4, true>;
1458 /******************************** Storage and SubImage Test Implementation ********************************/
1460 /** @brief Storage Test constructor.
1462 * @param [in] context OpenGL context.
1464 StorageAndSubImageTest::StorageAndSubImageTest(deqp::Context& context)
1465 : deqp::TestCase(context, "textures_storage_and_subimage", "Texture Storage and SubImage Test")
1472 /* Intentionally left blank. */
1475 /** @brief Count of reference data to be teted.
1477 * @tparam S Size (# of components).
1478 * @tparam D Texture dimenisons.
1482 template <glw::GLint S, glw::GLuint D>
1483 glw::GLuint StorageAndSubImageTest::TestReferenceDataCount()
1485 return 2 /* 1D */ * ((D > 1) ? 3 : 1) /* 2D */ * ((D > 2) ? 4 : 1) /* 3D */ * S /* components */;
1488 /** @brief Size of reference data to be teted.
1491 * @tparam S Size (# of components).
1492 * @tparam D Texture dimenisons.
1496 template <typename T, glw::GLint S, glw::GLuint D>
1497 glw::GLuint StorageAndSubImageTest::TestReferenceDataSize()
1499 return static_cast<glw::GLint>(TestReferenceDataCount<S, D>() * sizeof(T));
1502 /** @brief Height, width or depth of reference data to be teted.
1504 * @tparam D Texture dimenisons.
1506 * @return Height, width or depth.
1509 glw::GLuint StorageAndSubImageTest::TestReferenceDataHeight<2>()
1515 glw::GLuint StorageAndSubImageTest::TestReferenceDataHeight<3>()
1521 glw::GLuint StorageAndSubImageTest::TestReferenceDataDepth<3>()
1526 template <glw::GLuint D>
1527 glw::GLuint StorageAndSubImageTest::TestReferenceDataWidth()
1532 template <glw::GLuint D>
1533 glw::GLuint StorageAndSubImageTest::TestReferenceDataHeight()
1538 template <glw::GLuint D>
1539 glw::GLuint StorageAndSubImageTest::TestReferenceDataDepth()
1544 /** @brief Fragment shader declaration selector.
1547 * @tparam N Normalized flag.
1548 * @tparam D Texture dimenisons.
1550 * @return Frgment shader source code part.
1553 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLbyte, false, 1>()
1555 return s_fragment_shader_1D_fdecl_lowp;
1559 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLubyte, false, 1>()
1561 return s_fragment_shader_1D_idecl_lowp;
1565 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLshort, false, 1>()
1567 return s_fragment_shader_1D_udecl_lowp;
1571 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLushort, false, 1>()
1573 return s_fragment_shader_1D_fdecl_mediump;
1577 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLint, false, 1>()
1579 return s_fragment_shader_1D_idecl_mediump;
1583 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLuint, false, 1>()
1585 return s_fragment_shader_1D_udecl_mediump;
1589 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLubyte, true, 1>()
1591 return s_fragment_shader_1D_fdecl_highp;
1595 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLushort, true, 1>()
1597 return s_fragment_shader_1D_idecl_highp;
1601 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLfloat, true, 1>()
1603 return s_fragment_shader_1D_udecl_highp;
1607 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLbyte, false, 2>()
1609 return s_fragment_shader_2D_fdecl_lowp;
1613 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLubyte, false, 2>()
1615 return s_fragment_shader_2D_idecl_lowp;
1619 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLshort, false, 2>()
1621 return s_fragment_shader_2D_udecl_lowp;
1625 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLushort, false, 2>()
1627 return s_fragment_shader_2D_fdecl_mediump;
1631 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLint, false, 2>()
1633 return s_fragment_shader_2D_idecl_mediump;
1637 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLuint, false, 2>()
1639 return s_fragment_shader_2D_udecl_mediump;
1643 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLubyte, true, 2>()
1645 return s_fragment_shader_2D_fdecl_highp;
1649 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLushort, true, 2>()
1651 return s_fragment_shader_2D_idecl_highp;
1655 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLfloat, true, 2>()
1657 return s_fragment_shader_2D_udecl_highp;
1661 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLbyte, false, 3>()
1663 return s_fragment_shader_3D_fdecl_lowp;
1667 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLubyte, false, 3>()
1669 return s_fragment_shader_3D_idecl_lowp;
1673 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLshort, false, 3>()
1675 return s_fragment_shader_3D_udecl_lowp;
1679 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLushort, false, 3>()
1681 return s_fragment_shader_3D_fdecl_mediump;
1685 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLint, false, 3>()
1687 return s_fragment_shader_3D_idecl_mediump;
1691 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLuint, false, 3>()
1693 return s_fragment_shader_3D_udecl_mediump;
1697 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLubyte, true, 3>()
1699 return s_fragment_shader_3D_fdecl_highp;
1703 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLushort, true, 3>()
1705 return s_fragment_shader_3D_idecl_highp;
1709 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLfloat, true, 3>()
1711 return s_fragment_shader_3D_udecl_highp;
1714 /** @brief Fragment shader tail selector.
1716 * @tparam D Texture dimenisons.
1718 * @return Frgment shader source code part.
1721 const glw::GLchar* StorageAndSubImageTest::FragmentShaderTail<1>()
1723 return s_fragment_shader_1D_tail;
1727 const glw::GLchar* StorageAndSubImageTest::FragmentShaderTail<2>()
1729 return s_fragment_shader_2D_tail;
1733 const glw::GLchar* StorageAndSubImageTest::FragmentShaderTail<3>()
1735 return s_fragment_shader_3D_tail;
1738 /** @brief Texture target selector.
1740 * @tparam D Texture dimenisons.
1742 * @return Texture target.
1745 glw::GLenum StorageAndSubImageTest::TextureTarget<1>()
1747 return GL_TEXTURE_1D;
1751 glw::GLenum StorageAndSubImageTest::TextureTarget<2>()
1753 return GL_TEXTURE_2D;
1757 glw::GLenum StorageAndSubImageTest::TextureTarget<3>()
1759 return GL_TEXTURE_3D;
1762 /** @brief TextureStorage* wrapper.
1764 * @tparam D Texture dimenisons.
1765 * @tparam I Select between legacy/DSA way.
1767 * @return true if suuceed (in legacy always or throw), false otherwise.
1770 bool StorageAndSubImageTest::TextureStorage<1, true>(glw::GLenum target, glw::GLuint texture, glw::GLsizei levels,
1771 glw::GLenum internalformat, glw::GLsizei width,
1772 glw::GLsizei height, glw::GLsizei depth)
1777 /* Shortcut for GL functionality. */
1778 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1780 /* Preparing storage. */
1781 gl.texStorage1D(target, levels, internalformat, width);
1782 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage1D has failed");
1784 /* TextureSubImage* (not TextureStorage*) is tested so here we only throw when error occurs. */
1788 /** @brief TextureStorage* wrapper.
1790 * @tparam D Texture dimenisons.
1791 * @tparam I Select between legacy/DSA way.
1793 * @return true if suuceed (in legacy always or throw), false otherwise.
1796 bool StorageAndSubImageTest::TextureStorage<2, true>(glw::GLenum target, glw::GLuint texture, glw::GLsizei levels,
1797 glw::GLenum internalformat, glw::GLsizei width,
1798 glw::GLsizei height, glw::GLsizei depth)
1802 /* Shortcut for GL functionality. */
1803 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1805 /* Preparing storage. */
1806 gl.texStorage2D(target, levels, internalformat, width, height);
1807 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage2D has failed");
1809 /* TextureSubImage* (not TextureStorage*) is tested so here we only throw when error occurs. */
1813 /** @brief TextureStorage* wrapper.
1815 * @tparam D Texture dimenisons.
1816 * @tparam I Select between legacy/DSA way.
1818 * @return true if suuceed (in legacy always or throw), false otherwise.
1821 bool StorageAndSubImageTest::TextureStorage<3, true>(glw::GLenum target, glw::GLuint texture, glw::GLsizei levels,
1822 glw::GLenum internalformat, glw::GLsizei width,
1823 glw::GLsizei height, glw::GLsizei depth)
1826 /* Shortcut for GL functionality. */
1827 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1829 /* Preparing storage. */
1830 gl.texStorage3D(target, levels, internalformat, width, height, depth);
1831 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage3D has failed");
1833 /* TextureSubImage* (not TextureStorage*) is tested so here we only throw when error occurs. */
1837 /** @brief TextureStorage* wrapper.
1839 * @tparam D Texture dimenisons.
1840 * @tparam I Select between legacy/DSA way.
1842 * @return true if suuceed (in legacy always or throw), false otherwise.
1845 bool StorageAndSubImageTest::TextureStorage<1, false>(glw::GLenum target, glw::GLuint texture, glw::GLsizei levels,
1846 glw::GLenum internalformat, glw::GLsizei width,
1847 glw::GLsizei height, glw::GLsizei depth)
1852 /* Shortcut for GL functionality. */
1853 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1855 /* Preparing storage. */
1856 gl.textureStorage1D(texture, levels, internalformat, width);
1858 /* Error checking. */
1861 if (GL_NO_ERROR != (error = gl.getError()))
1864 m_context.getTestContext().getLog()
1865 << tcu::TestLog::Message << "glTextureStorage1D unexpectedly generated error " << glu::getErrorStr(error)
1866 << " during test with levels " << levels << ", internal format " << internalformat << " and width " << width
1867 << "." << tcu::TestLog::EndMessage;
1878 /** @brief TextureStorage* wrapper.
1880 * @tparam D Texture dimenisons.
1881 * @tparam I Select between legacy/DSA way.
1883 * @return true if suuceed (in legacy always or throw), false otherwise.
1886 bool StorageAndSubImageTest::TextureStorage<2, false>(glw::GLenum target, glw::GLuint texture, glw::GLsizei levels,
1887 glw::GLenum internalformat, glw::GLsizei width,
1888 glw::GLsizei height, glw::GLsizei depth)
1892 /* Shortcut for GL functionality. */
1893 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1895 /* Preparing storage. */
1896 gl.textureStorage2D(texture, levels, internalformat, width, height);
1898 /* Error checking. */
1901 if (GL_NO_ERROR != (error = gl.getError()))
1904 m_context.getTestContext().getLog()
1905 << tcu::TestLog::Message << "glTextureStorage2D unexpectedly generated error " << glu::getErrorStr(error)
1906 << " during test with levels " << levels << ", internal format " << internalformat << ", width " << width
1907 << " and height " << height << "." << tcu::TestLog::EndMessage;
1918 /** @brief TextureStorage* wrapper.
1920 * @tparam D Texture dimenisons.
1921 * @tparam I Select between legacy/DSA way.
1923 * @return true if suuceed (in legacy always or throw), false otherwise.
1926 bool StorageAndSubImageTest::TextureStorage<3, false>(glw::GLenum target, glw::GLuint texture, glw::GLsizei levels,
1927 glw::GLenum internalformat, glw::GLsizei width,
1928 glw::GLsizei height, glw::GLsizei depth)
1931 /* Shortcut for GL functionality. */
1932 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1934 /* Preparing storage. */
1935 gl.textureStorage3D(texture, levels, internalformat, width, height, depth);
1937 /* Error checking. */
1940 if (GL_NO_ERROR != (error = gl.getError()))
1943 m_context.getTestContext().getLog()
1944 << tcu::TestLog::Message << "glTextureStorage3D unexpectedly generated error " << glu::getErrorStr(error)
1945 << " during test with levels " << levels << ", internal format " << glu::getTextureFormatStr(internalformat)
1946 << ", width " << width << ", height " << height << " and depth " << depth << "."
1947 << tcu::TestLog::EndMessage;
1958 /** @brief TextureSubImage* wrapper.
1960 * @tparam D Texture dimenisons.
1961 * @tparam I Select between legacy/DSA way.
1963 * @return true if suuceed (in legacy always or throw), false otherwise.
1966 bool StorageAndSubImageTest::TextureSubImage<1, false>(glw::GLenum target, glw::GLuint texture, glw::GLint level,
1967 glw::GLint internalformat, glw::GLsizei width,
1968 glw::GLsizei height, glw::GLsizei depth, glw::GLenum format,
1969 glw::GLenum type, const glw::GLvoid* data)
1972 (void)internalformat;
1975 /* Shortcut for GL functionality. */
1976 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1979 gl.texSubImage1D(target, level, 0, width, format, type, data);
1980 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexSubImage1D has failed");
1982 /* TextureStorage* (not TextureSubImage) is tested so here we only throw when error occurs. */
1986 /** @brief TextureSubImage* wrapper.
1988 * @tparam D Texture dimenisons.
1989 * @tparam I Select between legacy/DSA way.
1991 * @return true if suuceed (in legacy always or throw), false otherwise.
1994 bool StorageAndSubImageTest::TextureSubImage<2, false>(glw::GLenum target, glw::GLuint texture, glw::GLint level,
1995 glw::GLint internalformat, glw::GLsizei width,
1996 glw::GLsizei height, glw::GLsizei depth, glw::GLenum format,
1997 glw::GLenum type, const glw::GLvoid* data)
2000 (void)internalformat;
2002 /* Shortcut for GL functionality. */
2003 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2006 gl.texSubImage2D(target, level, 0, 0, width, height, format, type, data);
2007 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexSubImage2D has failed");
2009 /* TextureStorage* (not TextureSubImage) is tested so here we only throw when error occurs. */
2013 /** @brief TextureSubImage* wrapper.
2015 * @tparam D Texture dimenisons.
2016 * @tparam I Select between legacy/DSA way.
2018 * @return true if suuceed (in legacy always or throw), false otherwise.
2021 bool StorageAndSubImageTest::TextureSubImage<3, false>(glw::GLenum target, glw::GLuint texture, glw::GLint level,
2022 glw::GLint internalformat, glw::GLsizei width,
2023 glw::GLsizei height, glw::GLsizei depth, glw::GLenum format,
2024 glw::GLenum type, const glw::GLvoid* data)
2027 (void)internalformat;
2028 /* Shortcut for GL functionality. */
2029 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2032 gl.texSubImage3D(target, level, 0, 0, 0, width, height, depth, format, type, data);
2033 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexSubImage3D has failed");
2035 /* TextureStorage* (not TextureSubImage) is tested so here we only throw when error occurs. */
2039 /** @brief TextureSubImage* wrapper.
2041 * @tparam D Texture dimenisons.
2042 * @tparam I Select between legacy/DSA way.
2044 * @return true if suuceed (in legacy always or throw), false otherwise.
2047 bool StorageAndSubImageTest::TextureSubImage<1, true>(glw::GLenum target, glw::GLuint texture, glw::GLint level,
2048 glw::GLint internalformat, glw::GLsizei width,
2049 glw::GLsizei height, glw::GLsizei depth, glw::GLenum format,
2050 glw::GLenum type, const glw::GLvoid* data)
2053 (void)internalformat;
2056 /* Shortcut for GL functionality. */
2057 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2060 gl.textureSubImage1D(texture, level, 0, width, format, type, data);
2062 /* Error checking. */
2065 if (GL_NO_ERROR != (error = gl.getError()))
2068 m_context.getTestContext().getLog()
2069 << tcu::TestLog::Message << "glTextureSubImage1D unexpectedly generated error " << glu::getErrorStr(error)
2070 << " during test with level " << level << ", width " << width << ", format "
2071 << glu::getTextureFormatStr(format) << " and type " << glu::getTypeStr(type) << "."
2072 << tcu::TestLog::EndMessage;
2083 /** @brief TextureSubImage* wrapper.
2085 * @tparam D Texture dimenisons.
2086 * @tparam I Select between legacy/DSA way.
2088 * @return true if suuceed (in legacy always or throw), false otherwise.
2091 bool StorageAndSubImageTest::TextureSubImage<2, true>(glw::GLenum target, glw::GLuint texture, glw::GLint level,
2092 glw::GLint internalformat, glw::GLsizei width,
2093 glw::GLsizei height, glw::GLsizei depth, glw::GLenum format,
2094 glw::GLenum type, const glw::GLvoid* data)
2097 (void)internalformat;
2099 /* Shortcut for GL functionality. */
2100 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2103 gl.textureSubImage2D(texture, level, 0, 0, width, height, format, type, data);
2105 /* Error checking. */
2108 if (GL_NO_ERROR != (error = gl.getError()))
2111 m_context.getTestContext().getLog()
2112 << tcu::TestLog::Message << "glTextureSubImage2D unexpectedly generated error " << glu::getErrorStr(error)
2113 << " during test with level " << level << ", width " << width << ", height " << height << ", format "
2114 << glu::getTextureFormatStr(format) << " and type " << glu::getTypeStr(type) << "."
2115 << tcu::TestLog::EndMessage;
2126 /** @brief TextureSubImage* wrapper.
2128 * @tparam D Texture dimenisons.
2129 * @tparam I Select between legacy/DSA way.
2131 * @return true if suuceed (in legacy always or throw), false otherwise.
2134 bool StorageAndSubImageTest::TextureSubImage<3, true>(glw::GLenum target, glw::GLuint texture, glw::GLint level,
2135 glw::GLint internalformat, glw::GLsizei width,
2136 glw::GLsizei height, glw::GLsizei depth, glw::GLenum format,
2137 glw::GLenum type, const glw::GLvoid* data)
2140 (void)internalformat;
2141 /* Shortcut for GL functionality. */
2142 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2145 gl.textureSubImage3D(texture, level, 0, 0, 0, width, height, depth, format, type, data);
2147 /* Error checking. */
2150 if (GL_NO_ERROR != (error = gl.getError()))
2153 m_context.getTestContext().getLog()
2154 << tcu::TestLog::Message << "glTextureSubImage3D unexpectedly generated error " << glu::getErrorStr(error)
2155 << " during test with level " << level << ", width " << width << ", height " << height << ", depth "
2156 << depth << ", format " << glu::getTextureFormatStr(format) << " and type " << glu::getTypeStr(type) << "."
2157 << tcu::TestLog::EndMessage;
2168 /** @brief Create texture.
2171 * @tparam S Size (# of components).
2172 * @tparam N Is normalized.
2173 * @tparam D Dimmensions.
2174 * @tparam I Test SubImage or Storage.
2176 * @return True if succeded, false otherwise.
2178 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2179 bool StorageAndSubImageTest::CreateTexture()
2181 /* Shortcut for GL functionality. */
2182 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2184 /* Objects creation. */
2185 gl.genTextures(1, &m_to);
2186 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
2188 gl.bindTexture(TextureTarget<D>(), m_to);
2189 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
2191 /* Storage creation. */
2192 if (TextureStorage<D, I>(TextureTarget<D>(), m_to, 1, InternalFormat<T, S, N>(), TestReferenceDataWidth<D>(),
2193 TestReferenceDataHeight<D>(), TestReferenceDataDepth<D>()))
2196 if (TextureSubImage<D, I>(TextureTarget<D>(), m_to, 0, InternalFormat<T, S, N>(), TestReferenceDataWidth<D>(),
2197 TestReferenceDataHeight<D>(), TestReferenceDataDepth<D>(), Format<S, N>(), Type<T>(),
2198 ReferenceData<T, N>()))
2200 glTexParameteri(TextureTarget<D>(), GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2201 glTexParameteri(TextureTarget<D>(), GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2211 /** @brief Compre results with the reference.
2214 * @tparam S Size (# of components).
2215 * @tparam N Is normalized.
2217 * @return True if equal, false otherwise.
2219 template <typename T, glw::GLint S, bool N, glw::GLuint D>
2220 bool StorageAndSubImageTest::Check()
2222 /* Shortcut for GL functionality. */
2223 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2225 /* Fetching data. */
2226 std::vector<T> result(TestReferenceDataCount<S, D>());
2228 gl.pixelStorei(GL_UNPACK_ALIGNMENT, sizeof(T));
2229 GLU_EXPECT_NO_ERROR(gl.getError(), "glPixelStorei has failed");
2231 gl.pixelStorei(GL_PACK_ALIGNMENT, sizeof(T));
2232 GLU_EXPECT_NO_ERROR(gl.getError(), "glPixelStorei has failed");
2234 glw::GLuint fbo_size_x = 0;
2245 fbo_size_x = 2 * 3 * 4;
2251 gl.readnPixels(0, 0, fbo_size_x, 1, Format<S, N>(), Type<T>(), TestReferenceDataSize<T, S, D>(),
2252 (glw::GLvoid*)(&result[0]));
2253 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels has failed");
2256 for (glw::GLuint i = 0; i < TestReferenceDataCount<S, D>(); ++i)
2258 if (!Compare<T>(result[i], ReferenceData<T, N>()[i]))
2267 /** @brief Test case function.
2270 * @tparam S Size (# of components).
2271 * @tparam N Is normalized.
2272 * @tparam D Number of texture dimensions.
2274 * @return True if test succeeded, false otherwise.
2276 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2277 bool StorageAndSubImageTest::Test()
2280 PrepareFramebuffer(InternalFormat<T, S, N>(), D);
2282 if (!CreateTexture<T, S, N, D, I>())
2290 /* Compare results with reference. */
2291 bool result = Check<T, S, N, D>();
2302 /** @brief Lopp test function over S.
2305 * @tparam N Is normalized.
2306 * @tparam D Texture dimension.
2307 * @tparam I Choose between SubImage and Storage tests.
2309 * @param [in] skip_rgb Skip test of S = 3 (needed for some formats).
2311 * @return True if tests succeeded, false otherwise.
2313 template <typename T, bool N, glw::GLuint D, bool I>
2314 bool StorageAndSubImageTest::LoopTestOverS(bool skip_rgb)
2316 /* Prepare one program per test loop. */
2317 PrepareProgram(FragmentShaderDeclaration<T, N, D>(), FragmentShaderTail<D>());
2322 result &= Test<T, 1, N, D, I>();
2324 result &= Test<T, 2, N, D, I>();
2328 result &= Test<T, 3, N, D, I>();
2331 result &= Test<T, 4, N, D, I>();
2341 /** @brief Lopp test function over D and over S.
2344 * @tparam N Is normalized.
2345 * @tparam I Choose between SubImage and Storage tests.
2347 * @param [in] skip_rgb Skip test of S = 3 (needed for some formats).
2349 * @return True if tests succeeded, false otherwise.
2351 template <typename T, bool N, bool I>
2352 bool StorageAndSubImageTest::LoopTestOverDOverS(bool skip_rgb)
2356 result &= LoopTestOverS<T, N, 1, I>(skip_rgb);
2357 result &= LoopTestOverS<T, N, 2, I>(skip_rgb);
2358 result &= LoopTestOverS<T, N, 3, I>(skip_rgb);
2363 /** @brief Function prepares framebuffer with internal format color attachment.
2364 * Viewport is set up. Content of the framebuffer is cleared.
2366 * @note The function may throw if unexpected error has occured.
2368 void StorageAndSubImageTest::PrepareFramebuffer(const glw::GLenum internal_format, const glw::GLuint D)
2370 /* Shortcut for GL functionality. */
2371 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2373 /* Prepare framebuffer. */
2374 gl.genFramebuffers(1, &m_fbo);
2375 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
2377 gl.genRenderbuffers(1, &m_rbo);
2378 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
2380 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
2381 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
2383 gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo);
2384 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
2386 glw::GLuint fbo_size_x = 0;
2397 fbo_size_x = 2 * 3 * 4;
2403 gl.renderbufferStorage(GL_RENDERBUFFER, internal_format, fbo_size_x, 1);
2404 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage call failed.");
2406 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo);
2407 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer call failed.");
2409 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
2414 gl.viewport(0, 0, fbo_size_x, 1);
2415 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
2417 /* Clear framebuffer's content. */
2418 gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
2419 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor call failed.");
2421 gl.clear(GL_COLOR_BUFFER_BIT);
2422 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear call failed.");
2425 /** @brief Prepare program
2427 * @param [in] variable_declaration Variables declaration part of fragment shader source code.
2428 * @param [in] tail Tail part of fragment shader source code.
2430 void StorageAndSubImageTest::PrepareProgram(const glw::GLchar* variable_declaration, const glw::GLchar* tail)
2432 /* Shortcut for GL functionality */
2433 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2437 glw::GLchar const* source[3];
2438 glw::GLsizei const count;
2439 glw::GLenum const type;
2441 } shader[] = { { { s_vertex_shader, NULL, NULL }, 1, GL_VERTEX_SHADER, 0 },
2442 { { s_fragment_shader_head, variable_declaration, tail }, 3, GL_FRAGMENT_SHADER, 0 } };
2444 glw::GLuint const shader_count = sizeof(shader) / sizeof(shader[0]);
2448 /* Create program. */
2449 m_po = gl.createProgram();
2450 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateProgram call failed.");
2452 /* Shader compilation. */
2454 for (glw::GLuint i = 0; i < shader_count; ++i)
2457 shader[i].id = gl.createShader(shader[i].type);
2459 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateShader call failed.");
2461 gl.attachShader(m_po, shader[i].id);
2463 GLU_EXPECT_NO_ERROR(gl.getError(), "glAttachShader call failed.");
2465 gl.shaderSource(shader[i].id, shader[i].count, shader[i].source, NULL);
2467 GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource call failed.");
2469 gl.compileShader(shader[i].id);
2471 GLU_EXPECT_NO_ERROR(gl.getError(), "glCompileShader call failed.");
2473 glw::GLint status = GL_FALSE;
2475 gl.getShaderiv(shader[i].id, GL_COMPILE_STATUS, &status);
2476 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv call failed.");
2478 if (GL_FALSE == status)
2480 glw::GLint log_size = 0;
2481 gl.getShaderiv(shader[i].id, GL_INFO_LOG_LENGTH, &log_size);
2482 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv call failed.");
2484 glw::GLchar* log_text = new glw::GLchar[log_size];
2486 gl.getShaderInfoLog(shader[i].id, log_size, NULL, &log_text[0]);
2488 m_context.getTestContext().getLog()
2489 << tcu::TestLog::Message << "Shader compilation has failed.\n"
2490 << "Shader type: " << glu::getShaderTypeStr(shader[i].type) << "\n"
2491 << "Shader compilation error log:\n"
2493 << "Shader source code:\n"
2494 << shader[i].source[0] << (shader[i].source[1] ? shader[i].source[1] : "")
2495 << (shader[i].source[2] ? shader[i].source[2] : "") << "\n"
2496 << tcu::TestLog::EndMessage;
2500 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderInfoLog call failed.");
2508 gl.linkProgram(m_po);
2510 GLU_EXPECT_NO_ERROR(gl.getError(), "glTransformFeedbackVaryings call failed.");
2512 glw::GLint status = GL_FALSE;
2514 gl.getProgramiv(m_po, GL_LINK_STATUS, &status);
2516 if (GL_TRUE == status)
2518 for (glw::GLuint i = 0; i < shader_count; ++i)
2522 gl.detachShader(m_po, shader[i].id);
2524 GLU_EXPECT_NO_ERROR(gl.getError(), "glDetachShader call failed.");
2530 glw::GLint log_size = 0;
2532 gl.getProgramiv(m_po, GL_INFO_LOG_LENGTH, &log_size);
2534 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramiv call failed.");
2536 glw::GLchar* log_text = new glw::GLchar[log_size];
2538 gl.getProgramInfoLog(m_po, log_size, NULL, &log_text[0]);
2540 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Program linkage has failed due to:\n"
2542 << tcu::TestLog::EndMessage;
2546 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramInfoLog call failed.");
2555 gl.deleteProgram(m_po);
2561 for (glw::GLuint i = 0; i < shader_count; ++i)
2563 if (0 != shader[i].id)
2565 gl.deleteShader(shader[i].id);
2577 /** @brief Prepare VAO.
2579 void StorageAndSubImageTest::PrepareVertexArray()
2581 /* Shortcut for GL functionality. */
2582 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2584 gl.genVertexArrays(1, &m_vao);
2585 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays has failed");
2587 gl.bindVertexArray(m_vao);
2588 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray has failed");
2591 /** @brief Test's draw call.
2593 void StorageAndSubImageTest::Draw()
2595 /* Shortcut for GL functionality. */
2596 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2598 gl.useProgram(m_po);
2599 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram has failed");
2601 gl.activeTexture(GL_TEXTURE0);
2602 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
2604 gl.bindTextureUnit(0, m_to);
2605 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
2607 gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
2608 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays has failed");
2611 /** @brief Clean GL objects, test variables and GL errors.
2613 void StorageAndSubImageTest::CleanTexture()
2615 /* Shortcut for GL functionality. */
2616 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2621 gl.deleteTextures(1, &m_to);
2627 /** @brief Clean GL objects, test variables and GL errors.
2629 void StorageAndSubImageTest::CleanFramebuffer()
2631 /* Shortcut for GL functionality. */
2632 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2637 gl.deleteFramebuffers(1, &m_fbo);
2645 gl.deleteRenderbuffers(1, &m_rbo);
2651 /** @brief Clean GL objects, test variables and GL errors.
2653 void StorageAndSubImageTest::CleanProgram()
2655 /* Shortcut for GL functionality. */
2656 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2663 gl.deleteProgram(m_po);
2669 /** @brief Clean GL objects, test variables and GL errors.
2671 void StorageAndSubImageTest::CleanErrors()
2673 /* Shortcut for GL functionality. */
2674 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2676 /* Query all errors until GL_NO_ERROR occure. */
2677 while (GL_NO_ERROR != gl.getError())
2681 /** @brief Clean GL objects, test variables and GL errors.
2683 void StorageAndSubImageTest::CleanVertexArray()
2685 /* Shortcut for GL functionality. */
2686 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2690 gl.bindVertexArray(0);
2692 gl.deleteVertexArrays(1, &m_vao);
2698 /** @brief Iterate Storage Test cases.
2700 * @return Iteration result.
2702 tcu::TestNode::IterateResult StorageAndSubImageTest::iterate()
2704 /* Shortcut for GL functionality. */
2705 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2707 /* Get context setup. */
2708 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
2709 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
2711 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
2713 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
2718 /* Running tests. */
2720 bool is_error = false;
2724 PrepareVertexArray();
2726 /* Test TextureStorage* */
2727 is_ok &= LoopTestOverDOverS<glw::GLbyte, false, false>(true);
2728 is_ok &= LoopTestOverDOverS<glw::GLubyte, false, false>(true);
2729 is_ok &= LoopTestOverDOverS<glw::GLshort, false, false>(true);
2730 is_ok &= LoopTestOverDOverS<glw::GLushort, false, false>(true);
2731 is_ok &= LoopTestOverDOverS<glw::GLint, false, false>(false);
2732 is_ok &= LoopTestOverDOverS<glw::GLuint, false, false>(false);
2733 is_ok &= LoopTestOverDOverS<glw::GLubyte, true, false>(true);
2734 is_ok &= LoopTestOverDOverS<glw::GLushort, true, false>(true);
2735 is_ok &= LoopTestOverDOverS<glw::GLfloat, true, false>(false);
2737 /* Test TextureSubImage* */
2738 is_ok &= LoopTestOverDOverS<glw::GLbyte, false, true>(true);
2739 is_ok &= LoopTestOverDOverS<glw::GLubyte, false, true>(true);
2740 is_ok &= LoopTestOverDOverS<glw::GLshort, false, true>(true);
2741 is_ok &= LoopTestOverDOverS<glw::GLushort, false, true>(true);
2742 is_ok &= LoopTestOverDOverS<glw::GLint, false, true>(false);
2743 is_ok &= LoopTestOverDOverS<glw::GLuint, false, true>(false);
2744 is_ok &= LoopTestOverDOverS<glw::GLubyte, true, true>(true);
2745 is_ok &= LoopTestOverDOverS<glw::GLushort, true, true>(true);
2746 is_ok &= LoopTestOverDOverS<glw::GLfloat, true, true>(false);
2761 /* Errors clean up. */
2762 while (gl.getError())
2765 /* Result's setup. */
2768 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
2774 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
2778 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
2785 /* Vertex shader source code. */
2786 const glw::GLchar* StorageAndSubImageTest::s_vertex_shader = "#version 450\n"
2790 " switch(gl_VertexID)\n"
2793 " gl_Position = vec4(-1.0, 1.0, 0.0, 1.0);\n"
2796 " gl_Position = vec4( 1.0, 1.0, 0.0, 1.0);\n"
2799 " gl_Position = vec4(-1.0,-1.0, 0.0, 1.0);\n"
2802 " gl_Position = vec4( 1.0,-1.0, 0.0, 1.0);\n"
2807 /* Fragment shader source program. */
2808 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_head =
2811 "layout(pixel_center_integer) in vec4 gl_FragCoord;\n"
2814 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_1D_fdecl_lowp =
2815 "uniform sampler1D texture_input;\nout vec4 texture_output;\n";
2816 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_1D_idecl_lowp =
2817 "uniform isampler1D texture_input;\nout ivec4 texture_output;\n";
2818 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_1D_udecl_lowp =
2819 "uniform usampler1D texture_input;\nout uvec4 texture_output;\n";
2820 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_1D_fdecl_mediump =
2821 "uniform sampler1D texture_input;\nout vec4 texture_output;\n";
2822 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_1D_idecl_mediump =
2823 "uniform isampler1D texture_input;\nout ivec4 texture_output;\n";
2824 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_1D_udecl_mediump =
2825 "uniform usampler1D texture_input;\nout uvec4 texture_output;\n";
2826 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_1D_fdecl_highp =
2827 "uniform sampler1D texture_input;\nout vec4 texture_output;\n";
2828 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_1D_idecl_highp =
2829 "uniform isampler1D texture_input;\nout ivec4 texture_output;\n";
2830 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_1D_udecl_highp =
2831 "uniform usampler1D texture_input;\nout uvec4 texture_output;\n";
2833 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_2D_fdecl_lowp =
2834 "uniform sampler2D texture_input;\nout vec4 texture_output;\n";
2835 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_2D_idecl_lowp =
2836 "uniform isampler2D texture_input;\nout ivec4 texture_output;\n";
2837 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_2D_udecl_lowp =
2838 "uniform usampler2D texture_input;\nout uvec4 texture_output;\n";
2839 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_2D_fdecl_mediump =
2840 "uniform sampler2D texture_input;\nout vec4 texture_output;\n";
2841 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_2D_idecl_mediump =
2842 "uniform isampler2D texture_input;\nout ivec4 texture_output;\n";
2843 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_2D_udecl_mediump =
2844 "uniform usampler2D texture_input;\nout uvec4 texture_output;\n";
2845 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_2D_fdecl_highp =
2846 "uniform sampler2D texture_input;\nout vec4 texture_output;\n";
2847 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_2D_idecl_highp =
2848 "uniform isampler2D texture_input;\nout ivec4 texture_output;\n";
2849 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_2D_udecl_highp =
2850 "uniform usampler2D texture_input;\nout uvec4 texture_output;\n";
2852 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_3D_fdecl_lowp =
2853 "uniform sampler3D texture_input;\nout vec4 texture_output;\n";
2854 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_3D_idecl_lowp =
2855 "uniform isampler3D texture_input;\nout ivec4 texture_output;\n";
2856 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_3D_udecl_lowp =
2857 "uniform usampler3D texture_input;\nout uvec4 texture_output;\n";
2858 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_3D_fdecl_mediump =
2859 "uniform sampler3D texture_input;\nout vec4 texture_output;\n";
2860 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_3D_idecl_mediump =
2861 "uniform isampler3D texture_input;\nout ivec4 texture_output;\n";
2862 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_3D_udecl_mediump =
2863 "uniform usampler3D texture_input;\nout uvec4 texture_output;\n";
2864 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_3D_fdecl_highp =
2865 "uniform sampler3D texture_input;\nout vec4 texture_output;\n";
2866 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_3D_idecl_highp =
2867 "uniform isampler3D texture_input;\nout ivec4 texture_output;\n";
2868 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_3D_udecl_highp =
2869 "uniform usampler3D texture_input;\nout uvec4 texture_output;\n";
2871 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_1D_tail =
2875 " texture_output = texelFetch(texture_input, int(gl_FragCoord.x), 0);\n"
2878 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_2D_tail =
2882 " texture_output = texelFetch(texture_input, ivec2(int(gl_FragCoord.x) % 2, int(floor(gl_FragCoord.x / 2))), "
2886 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_3D_tail =
2890 " texture_output = texelFetch(texture_input, ivec3(int(gl_FragCoord.x) % 2, int(floor(gl_FragCoord.x / 2)) % 3, "
2891 "int(floor(gl_FragCoord.x / 2 / 3))), 0);\n"
2894 /******************************** Storage Multisample Test Implementation ********************************/
2896 /** @brief Storage Multisample Test constructor.
2898 * @param [in] context OpenGL context.
2900 StorageMultisampleTest::StorageMultisampleTest(deqp::Context& context)
2901 : deqp::TestCase(context, "textures_storage_multisample", "Texture Storage Multisample Test")
2911 /* Intentionally left blank. */
2914 /** @brief Count of reference data to be teted.
2916 * @tparam S Size (# of components).
2917 * @tparam D Texture dimenisons.
2921 template <glw::GLint S, glw::GLuint D>
2922 glw::GLuint StorageMultisampleTest::TestReferenceDataCount()
2924 return 2 /* 1D */ * ((D > 1) ? 3 : 1) /* 2D */ * ((D > 2) ? 4 : 1) /* 3D */ * S /* components */;
2927 /** @brief Size of reference data to be teted.
2930 * @tparam S Size (# of components).
2931 * @tparam D Texture dimenisons.
2935 template <typename T, glw::GLint S, glw::GLuint D>
2936 glw::GLuint StorageMultisampleTest::TestReferenceDataSize()
2938 return TestReferenceDataCount<S, D>() * sizeof(T);
2941 /** @brief Height, width or depth of reference data to be teted.
2943 * @tparam D Texture dimenisons.
2945 * @return Height, width or depth.
2948 glw::GLuint StorageMultisampleTest::TestReferenceDataHeight<2>()
2954 glw::GLuint StorageMultisampleTest::TestReferenceDataHeight<3>()
2956 return TestReferenceDataHeight<2>();
2960 glw::GLuint StorageMultisampleTest::TestReferenceDataDepth<2>()
2966 glw::GLuint StorageMultisampleTest::TestReferenceDataDepth<3>()
2971 template <glw::GLuint D>
2972 glw::GLuint StorageMultisampleTest::TestReferenceDataWidth()
2977 /** @brief Fragment shader declaration selector.
2980 * @tparam N Normalized flag.
2981 * @tparam D Texture dimenisons.
2983 * @return Frgment shader source code part.
2986 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLubyte, true, 2>()
2988 return s_fragment_shader_ms_2D_fdecl_lowp;
2992 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLbyte, false, 2>()
2994 return s_fragment_shader_ms_2D_idecl_lowp;
2998 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLubyte, false, 2>()
3000 return s_fragment_shader_ms_2D_udecl_lowp;
3004 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLushort, true, 2>()
3006 return s_fragment_shader_ms_2D_fdecl_mediump;
3010 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLshort, false, 2>()
3012 return s_fragment_shader_ms_2D_idecl_mediump;
3016 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLushort, false, 2>()
3018 return s_fragment_shader_ms_2D_udecl_mediump;
3022 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLfloat, true, 2>()
3024 return s_fragment_shader_ms_2D_fdecl_highp;
3028 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLint, false, 2>()
3030 return s_fragment_shader_ms_2D_idecl_highp;
3034 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLuint, false, 2>()
3036 return s_fragment_shader_ms_2D_udecl_highp;
3039 /** @brief Fragment shader declaration selector.
3042 * @tparam N Normalized flag.
3043 * @tparam D Texture dimenisons.
3045 * @return Frgment shader source code part.
3048 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLubyte, true, 3>()
3050 return s_fragment_shader_ms_3D_fdecl_lowp;
3054 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLbyte, false, 3>()
3056 return s_fragment_shader_ms_3D_idecl_lowp;
3060 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLubyte, false, 3>()
3062 return s_fragment_shader_ms_3D_udecl_lowp;
3066 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLushort, true, 3>()
3068 return s_fragment_shader_ms_3D_fdecl_mediump;
3072 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLshort, false, 3>()
3074 return s_fragment_shader_ms_3D_idecl_mediump;
3078 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLushort, false, 3>()
3080 return s_fragment_shader_ms_3D_udecl_mediump;
3084 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLfloat, true, 3>()
3086 return s_fragment_shader_ms_3D_fdecl_highp;
3090 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLint, false, 3>()
3092 return s_fragment_shader_ms_3D_idecl_highp;
3096 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLuint, false, 3>()
3098 return s_fragment_shader_ms_3D_udecl_highp;
3101 /** @brief Fragment shader declaration selector.
3104 * @tparam N Normalized flag.
3105 * @tparam D Texture dimenisons.
3107 * @return Frgment shader source code part.
3110 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLubyte, true, 2>()
3112 return s_fragment_shader_aux_2D_fdecl_lowp;
3116 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLbyte, false, 2>()
3118 return s_fragment_shader_aux_2D_idecl_lowp;
3122 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLubyte, false, 2>()
3124 return s_fragment_shader_aux_2D_udecl_lowp;
3128 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLushort, true, 2>()
3130 return s_fragment_shader_aux_2D_fdecl_mediump;
3134 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLshort, false, 2>()
3136 return s_fragment_shader_aux_2D_idecl_mediump;
3140 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLushort, false, 2>()
3142 return s_fragment_shader_aux_2D_udecl_mediump;
3146 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLfloat, true, 2>()
3148 return s_fragment_shader_aux_2D_fdecl_highp;
3152 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLint, false, 2>()
3154 return s_fragment_shader_aux_2D_idecl_highp;
3158 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLuint, false, 2>()
3160 return s_fragment_shader_aux_2D_udecl_highp;
3163 /** @brief Fragment shader declaration selector.
3166 * @tparam N Normalized flag.
3167 * @tparam D Texture dimenisons.
3169 * @return Frgment shader source code part.
3172 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLubyte, true, 3>()
3174 return s_fragment_shader_aux_3D_fdecl_lowp;
3178 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLbyte, false, 3>()
3180 return s_fragment_shader_aux_3D_idecl_lowp;
3184 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLubyte, false, 3>()
3186 return s_fragment_shader_aux_3D_udecl_lowp;
3190 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLushort, true, 3>()
3192 return s_fragment_shader_aux_3D_fdecl_mediump;
3196 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLshort, false, 3>()
3198 return s_fragment_shader_aux_3D_idecl_mediump;
3202 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLushort, false, 3>()
3204 return s_fragment_shader_aux_3D_udecl_mediump;
3208 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLfloat, true, 3>()
3210 return s_fragment_shader_aux_3D_fdecl_highp;
3214 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLint, false, 3>()
3216 return s_fragment_shader_aux_3D_idecl_highp;
3220 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLuint, false, 3>()
3222 return s_fragment_shader_aux_3D_udecl_highp;
3225 /** @brief Fragment shader tail selector.
3227 * @tparam D Texture dimenisons.
3229 * @return Frgment shader source code part.
3232 const glw::GLchar* StorageMultisampleTest::FragmentShaderTail<2>()
3234 return s_fragment_shader_tail_2D;
3238 const glw::GLchar* StorageMultisampleTest::FragmentShaderTail<3>()
3240 return s_fragment_shader_tail_3D;
3243 /** @brief Texture target selector.
3245 * @tparam D Texture dimenisons.
3247 * @return Texture target.
3250 glw::GLenum StorageMultisampleTest::InputTextureTarget<2>()
3252 return GL_TEXTURE_2D;
3256 glw::GLenum StorageMultisampleTest::InputTextureTarget<3>()
3258 return GL_TEXTURE_2D_ARRAY;
3261 /** @brief Prepare texture data for input texture.
3263 * @tparam D Texture dimenisons.
3265 * @note parameters as passed to texImage*
3268 void StorageMultisampleTest::InputTextureImage<2>(const glw::GLenum internal_format, const glw::GLuint width,
3269 const glw::GLuint height, const glw::GLuint depth,
3270 const glw::GLenum format, const glw::GLenum type,
3271 const glw::GLvoid* data)
3274 /* Shortcut for GL functionality. */
3275 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3278 gl.texImage2D(InputTextureTarget<2>(), 0, internal_format, width, height, 0, format, type, data);
3279 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
3282 /** @brief Prepare texture data for input texture.
3284 * @tparam D Texture dimenisons.
3286 * @note parameters as passed to texImage*
3289 void StorageMultisampleTest::InputTextureImage<3>(const glw::GLenum internal_format, const glw::GLuint width,
3290 const glw::GLuint height, const glw::GLuint depth,
3291 const glw::GLenum format, const glw::GLenum type,
3292 const glw::GLvoid* data)
3294 /* Shortcut for GL functionality. */
3295 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3298 gl.texImage3D(InputTextureTarget<3>(), 0, internal_format, width, height, depth, 0, format, type, data);
3299 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
3302 /** @brief Create texture.
3305 * @tparam S Size (# of components).
3306 * @tparam N Is normalized.
3307 * @tparam D Dimmensions.
3309 template <typename T, glw::GLint S, bool N, glw::GLuint D>
3310 void StorageMultisampleTest::CreateInputTexture()
3312 /* Shortcut for GL functionality. */
3313 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3315 /* Objects creation. */
3316 gl.genTextures(1, &m_to);
3317 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
3319 gl.bindTexture(InputTextureTarget<D>(), m_to);
3320 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
3323 InputTextureImage<D>(InternalFormat<T, S, N>(), TestReferenceDataWidth<D>(), TestReferenceDataHeight<D>(),
3324 TestReferenceDataDepth<D>(), Format<S, N>(), Type<T>(), ReferenceData<T, N>());
3326 /* Parameter setup. */
3327 gl.texParameteri(InputTextureTarget<D>(), GL_TEXTURE_MAG_FILTER, GL_NEAREST);
3328 gl.texParameteri(InputTextureTarget<D>(), GL_TEXTURE_MIN_FILTER, GL_NEAREST);
3329 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri call failed.");
3332 /** @brief Compre results with the reference.
3335 * @tparam S Size (# of components).
3336 * @tparam N Is normalized.
3338 * @return True if equal, false otherwise.
3340 template <typename T, glw::GLint S, bool N, glw::GLuint D>
3341 bool StorageMultisampleTest::Check()
3343 /* Shortcut for GL functionality. */
3344 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3346 /* Fetching data fro auxiliary texture. */
3347 std::vector<T> result(TestReferenceDataCount<S, D>());
3349 gl.bindTexture(InputTextureTarget<D>() /* Auxiliary target is the same as input. */, m_to_aux);
3350 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
3352 gl.getTexImage(InputTextureTarget<D>() /* Auxiliary target is the same as input. */, 0, Format<S, N>(), Type<T>(),
3353 (glw::GLvoid*)(&result[0]));
3354 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexImage has failed");
3357 for (glw::GLuint i = 0; i < TestReferenceDataCount<S, D>(); ++i)
3359 if (!Compare<T>(result[i], ReferenceData<T, N>()[i]))
3368 /** @brief Test case function.
3371 * @tparam S Size (# of components).
3372 * @tparam N Is normalized.
3373 * @tparam D Number of texture dimensions.
3375 * @return True if test succeeded, false otherwise.
3377 template <typename T, glw::GLint S, bool N, glw::GLuint D>
3378 bool StorageMultisampleTest::Test()
3380 /* Shortcut for GL functionality. */
3381 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3384 gl.pixelStorei(GL_UNPACK_ALIGNMENT, sizeof(T));
3385 GLU_EXPECT_NO_ERROR(gl.getError(), "glPixelStorei has failed");
3387 gl.pixelStorei(GL_PACK_ALIGNMENT, sizeof(T));
3388 GLU_EXPECT_NO_ERROR(gl.getError(), "glPixelStorei has failed");
3390 CreateInputTexture<T, S, N, D>();
3392 if (!PrepareFramebufferMultisample<D>(InternalFormat<T, S, N>()))
3394 CleanInputTexture();
3399 PrepareFramebufferAuxiliary<D>(InternalFormat<T, S, N>());
3404 /* Compare results with reference. */
3405 bool result = Check<T, S, N, D>();
3408 CleanAuxiliaryTexture();
3409 CleanFramebuffers();
3410 CleanInputTexture();
3417 /** @brief Lopp test function over S.
3420 * @tparam N Is normalized.
3421 * @tparam D Texture dimension.
3423 * @param [in] skip_rgb Skip test of S = 3 (needed for some formats).
3425 * @return True if tests succeeded, false otherwise.
3427 template <typename T, bool N, glw::GLuint D>
3428 bool StorageMultisampleTest::LoopTestOverS(bool skip_rgb)
3430 /* Prepare one program to create multisample texture and one to copy it to regular texture. */
3431 m_po_ms = PrepareProgram(FragmentShaderDeclarationMultisample<T, N, D>(), FragmentShaderTail<D>());
3432 m_po_aux = PrepareProgram(FragmentShaderDeclarationAuxiliary<T, N, D>(), FragmentShaderTail<D>());
3437 result &= Test<T, 1, N, D>();
3439 result &= Test<T, 2, N, D>();
3443 result &= Test<T, 3, N, D>();
3446 result &= Test<T, 4, N, D>();
3456 /** @brief Lopp test function over D and next over S.
3459 * @tparam N Is normalized.
3461 * @param [in] skip_rgb Skip test of S = 3 (needed for some formats).
3463 * @return True if tests succeeded, false otherwise.
3465 template <typename T, bool N>
3466 bool StorageMultisampleTest::LoopTestOverDOverS(bool skip_rgb)
3470 result &= LoopTestOverS<T, N, 2>(skip_rgb);
3471 result &= LoopTestOverS<T, N, 3>(skip_rgb);
3476 /** @brief Function prepares framebuffer with internal format color attachment.
3477 * Viewport is set up. Content of the framebuffer is cleared.
3479 * @note The function may throw if unexpected error has occured.
3482 bool StorageMultisampleTest::PrepareFramebufferMultisample<2>(const glw::GLenum internal_format)
3484 /* Shortcut for GL functionality. */
3485 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3487 /* Prepare framebuffer. */
3488 gl.genFramebuffers(1, &m_fbo_ms);
3489 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
3491 gl.genTextures(1, &m_to_ms);
3492 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
3494 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_ms);
3495 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
3497 gl.bindTexture(GL_TEXTURE_2D_MULTISAMPLE, m_to_ms);
3498 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
3500 gl.textureStorage2DMultisample(m_to_ms, 1, internal_format, TestReferenceDataWidth<2>(),
3501 TestReferenceDataHeight<2>(), false);
3505 if (GL_NO_ERROR != (error = gl.getError()))
3507 CleanFramebuffers();
3509 m_context.getTestContext().getLog()
3510 << tcu::TestLog::Message << "glTextureStorage2DMultisample unexpectedly generated error "
3511 << glu::getErrorStr(error) << " during the test of internal format "
3512 << glu::getTextureFormatStr(internal_format) << ". Test fails." << tcu::TestLog::EndMessage;
3517 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, m_to_ms, 0);
3518 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer call failed.");
3520 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
3525 gl.viewport(0, 0, TestReferenceDataWidth<2>(), TestReferenceDataHeight<2>());
3526 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
3528 /* Clear framebuffer's content. */
3529 gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
3530 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor call failed.");
3532 gl.clear(GL_COLOR_BUFFER_BIT);
3533 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear call failed.");
3538 /** @brief Function prepares framebuffer with internal format color attachment.
3539 * Viewport is set up. Content of the framebuffer is cleared.
3541 * @note The function may throw if unexpected error has occured.
3544 bool StorageMultisampleTest::PrepareFramebufferMultisample<3>(const glw::GLenum internal_format)
3546 /* Shortcut for GL functionality. */
3547 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3549 /* Prepare framebuffer. */
3550 gl.genFramebuffers(1, &m_fbo_ms);
3551 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
3553 gl.genTextures(1, &m_to_ms);
3554 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
3556 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_ms);
3557 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
3559 gl.bindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, m_to_ms);
3560 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
3562 gl.textureStorage3DMultisample(m_to_ms, 1, internal_format, TestReferenceDataWidth<3>(),
3563 TestReferenceDataHeight<3>(), TestReferenceDataDepth<3>(), false);
3567 if (GL_NO_ERROR != (error = gl.getError()))
3569 CleanFramebuffers();
3571 m_context.getTestContext().getLog()
3572 << tcu::TestLog::Message << "glTextureStorage3DMultisample unexpectedly generated error "
3573 << glu::getErrorStr(error) << " during the test of internal format "
3574 << glu::getTextureFormatStr(internal_format) << ". Test fails." << tcu::TestLog::EndMessage;
3579 for (glw::GLuint i = 0; i < TestReferenceDataDepth<3>(); ++i)
3581 gl.framebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, m_to_ms, 0, i);
3582 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer call failed.");
3585 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
3590 gl.viewport(0, 0, TestReferenceDataWidth<3>(), TestReferenceDataHeight<3>());
3591 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
3593 /* Clear framebuffer's content. */
3594 gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
3595 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor call failed.");
3597 gl.clear(GL_COLOR_BUFFER_BIT);
3598 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear call failed.");
3603 /** @brief Function prepares framebuffer with internal format color attachment.
3604 * Viewport is set up. Content of the framebuffer is cleared.
3606 * @note The function may throw if unexpected error has occured.
3609 void StorageMultisampleTest::PrepareFramebufferAuxiliary<2>(const glw::GLenum internal_format)
3611 /* Shortcut for GL functionality. */
3612 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3614 /* Prepare framebuffer. */
3615 gl.genFramebuffers(1, &m_fbo_aux);
3616 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
3618 gl.genTextures(1, &m_to_aux);
3619 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
3621 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_aux);
3622 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
3624 gl.bindTexture(GL_TEXTURE_2D, m_to_aux);
3625 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
3627 gl.textureStorage2D(m_to_aux, 1, internal_format, TestReferenceDataWidth<2>(), TestReferenceDataHeight<2>());
3628 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage2D call failed.");
3630 /* Parameter setup. */
3631 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
3632 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
3633 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri call failed.");
3635 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_to_aux, 0);
3636 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer call failed.");
3638 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
3643 gl.viewport(0, 0, TestReferenceDataWidth<2>(), TestReferenceDataHeight<2>());
3644 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
3646 /* Clear framebuffer's content. */
3647 gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
3648 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor call failed.");
3650 gl.clear(GL_COLOR_BUFFER_BIT);
3651 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear call failed.");
3654 /** @brief Function prepares framebuffer with internal format color attachment.
3655 * Viewport is set up. Content of the framebuffer is cleared.
3657 * @note The function may throw if unexpected error has occured.
3660 void StorageMultisampleTest::PrepareFramebufferAuxiliary<3>(const glw::GLenum internal_format)
3662 /* Shortcut for GL functionality. */
3663 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3665 /* Prepare framebuffer. */
3666 gl.genFramebuffers(1, &m_fbo_aux);
3667 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
3669 gl.genTextures(1, &m_to_aux);
3670 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
3672 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_aux);
3673 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
3675 gl.bindTexture(GL_TEXTURE_2D_ARRAY, m_to_aux);
3676 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
3678 gl.textureStorage3D(m_to_aux, 1, internal_format, TestReferenceDataWidth<3>(), TestReferenceDataHeight<3>(),
3679 TestReferenceDataDepth<3>());
3680 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage3D call failed.");
3682 /* Parameter setup. */
3683 gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
3684 gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
3685 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri call failed.");
3687 for (glw::GLuint i = 0; i < TestReferenceDataDepth<3>(); ++i)
3689 gl.framebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, m_to_aux, 0, i);
3690 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer call failed.");
3693 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
3698 gl.viewport(0, 0, TestReferenceDataWidth<3>(), TestReferenceDataHeight<3>());
3699 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
3701 /* Clear framebuffer's content. */
3702 gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
3703 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor call failed.");
3705 gl.clear(GL_COLOR_BUFFER_BIT);
3706 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear call failed.");
3709 /** @brief Prepare program
3711 * @param [in] variable_declaration Variables declaration part of fragment shader source code.
3712 * @param [in] tail Tail part of fragment shader source code.
3714 glw::GLuint StorageMultisampleTest::PrepareProgram(const glw::GLchar* variable_declaration, const glw::GLchar* tail)
3716 /* Shortcut for GL functionality */
3717 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3721 glw::GLchar const* source[3];
3722 glw::GLsizei const count;
3723 glw::GLenum const type;
3725 } shader[] = { { { s_vertex_shader, NULL, NULL }, 1, GL_VERTEX_SHADER, 0 },
3726 { { s_fragment_shader_head, variable_declaration, tail }, 3, GL_FRAGMENT_SHADER, 0 } };
3728 glw::GLuint const shader_count = sizeof(shader) / sizeof(shader[0]);
3734 /* Create program. */
3735 po = gl.createProgram();
3736 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateProgram call failed.");
3738 /* Shader compilation. */
3740 for (glw::GLuint i = 0; i < shader_count; ++i)
3743 shader[i].id = gl.createShader(shader[i].type);
3745 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateShader call failed.");
3747 gl.attachShader(po, shader[i].id);
3749 GLU_EXPECT_NO_ERROR(gl.getError(), "glAttachShader call failed.");
3751 gl.shaderSource(shader[i].id, shader[i].count, shader[i].source, NULL);
3753 GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource call failed.");
3755 gl.compileShader(shader[i].id);
3757 GLU_EXPECT_NO_ERROR(gl.getError(), "glCompileShader call failed.");
3759 glw::GLint status = GL_FALSE;
3761 gl.getShaderiv(shader[i].id, GL_COMPILE_STATUS, &status);
3762 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv call failed.");
3764 if (GL_FALSE == status)
3766 glw::GLint log_size = 0;
3767 gl.getShaderiv(shader[i].id, GL_INFO_LOG_LENGTH, &log_size);
3768 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv call failed.");
3770 glw::GLchar* log_text = new glw::GLchar[log_size];
3772 gl.getShaderInfoLog(shader[i].id, log_size, NULL, &log_text[0]);
3774 m_context.getTestContext().getLog()
3775 << tcu::TestLog::Message << "Shader compilation has failed.\n"
3776 << "Shader type: " << glu::getShaderTypeStr(shader[i].type) << "\n"
3777 << "Shader compilation error log:\n"
3779 << "Shader source code:\n"
3780 << shader[i].source[0] << (shader[i].source[1] ? shader[i].source[1] : "")
3781 << (shader[i].source[2] ? shader[i].source[2] : "") << "\n"
3782 << tcu::TestLog::EndMessage;
3786 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderInfoLog call failed.");
3796 GLU_EXPECT_NO_ERROR(gl.getError(), "glTransformFeedbackVaryings call failed.");
3798 glw::GLint status = GL_FALSE;
3800 gl.getProgramiv(po, GL_LINK_STATUS, &status);
3802 if (GL_TRUE == status)
3804 for (glw::GLuint i = 0; i < shader_count; ++i)
3808 gl.detachShader(po, shader[i].id);
3810 GLU_EXPECT_NO_ERROR(gl.getError(), "glDetachShader call failed.");
3816 glw::GLint log_size = 0;
3818 gl.getProgramiv(po, GL_INFO_LOG_LENGTH, &log_size);
3820 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramiv call failed.");
3822 glw::GLchar* log_text = new glw::GLchar[log_size];
3824 gl.getProgramInfoLog(po, log_size, NULL, &log_text[0]);
3826 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Program linkage has failed due to:\n"
3828 << tcu::TestLog::EndMessage;
3832 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramInfoLog call failed.");
3841 gl.deleteProgram(po);
3847 for (glw::GLuint i = 0; i < shader_count; ++i)
3849 if (0 != shader[i].id)
3851 gl.deleteShader(shader[i].id);
3865 /** @brief Prepare VAO.
3867 void StorageMultisampleTest::PrepareVertexArray()
3869 /* Shortcut for GL functionality. */
3870 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3872 gl.genVertexArrays(1, &m_vao);
3873 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays has failed");
3875 gl.bindVertexArray(m_vao);
3876 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray has failed");
3879 /** @brief Draw call 2D.
3882 void StorageMultisampleTest::Draw<2>()
3884 /* Shortcut for GL functionality. */
3885 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3887 /* Prepare multisample texture using draw call. */
3889 /* Prepare framebuffer with multisample texture. */
3890 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_ms);
3891 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
3893 /* Use first program program. */
3894 gl.useProgram(m_po_ms);
3895 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram has failed");
3897 /* Prepare texture to be drawn with. */
3898 gl.activeTexture(GL_TEXTURE0);
3899 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
3901 gl.bindTexture(GL_TEXTURE_2D, m_to);
3902 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
3904 gl.uniform1i(gl.getUniformLocation(m_po_ms, "texture_input"), 0);
3905 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i or glGetUniformLocation has failed");
3908 gl.drawBuffer(GL_COLOR_ATTACHMENT0);
3909 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawBuffer has failed");
3912 gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
3913 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays has failed");
3915 /* Copy multisample texture to auxiliary texture using draw call. */
3917 /* Prepare framebuffer with auxiliary texture. */
3918 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_aux);
3919 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
3921 /* Use first program program. */
3922 gl.useProgram(m_po_aux);
3923 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram has failed");
3925 /* Prepare texture to be drawn with. */
3926 gl.activeTexture(GL_TEXTURE0);
3927 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
3929 gl.bindTexture(GL_TEXTURE_2D_MULTISAMPLE, m_to_ms);
3930 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
3932 gl.bindTextureUnit(0, m_to);
3934 gl.uniform1i(gl.getUniformLocation(m_po_aux, "texture_input"), 0);
3935 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i or glGetUniformLocation has failed");
3938 gl.drawBuffer(GL_COLOR_ATTACHMENT0);
3939 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawBuffer has failed");
3942 gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
3943 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays has failed");
3946 /** @brief Draw call 3D.
3949 void StorageMultisampleTest::Draw<3>()
3951 /* Shortcut for GL functionality. */
3952 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3954 /* Prepare multisample texture using draw call. */
3956 /* Prepare framebuffer with multisample texture. */
3957 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_ms);
3958 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
3960 /* Use first program program. */
3961 gl.useProgram(m_po_ms);
3962 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram has failed");
3964 /* Prepare texture to be drawn with. */
3965 gl.activeTexture(GL_TEXTURE0);
3966 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
3968 gl.bindTexture(GL_TEXTURE_2D_ARRAY, m_to);
3969 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
3971 gl.uniform1i(gl.getUniformLocation(m_po_ms, "texture_input"), 0);
3972 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i or glGetUniformLocation has failed");
3974 /* For each texture layer. */
3975 for (glw::GLuint i = 0; i < TestReferenceDataDepth<3>(); ++i)
3978 gl.drawBuffer(GL_COLOR_ATTACHMENT0 + i);
3979 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawBuffer has failed");
3981 gl.uniform1i(gl.getUniformLocation(m_po_aux, "texture_layer"), i);
3982 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i or glGetUniformLocation has failed");
3985 gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
3986 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays has failed");
3989 /* Copy multisample texture to auxiliary texture using draw call. */
3991 /* Prepare framebuffer with auxiliary texture. */
3992 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_aux);
3993 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
3995 /* Use first program program. */
3996 gl.useProgram(m_po_aux);
3997 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram has failed");
3999 /* Prepare texture to be drawn with. */
4000 gl.activeTexture(GL_TEXTURE0);
4001 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
4003 gl.bindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, m_to_ms);
4004 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
4006 gl.bindTextureUnit(0, m_to);
4008 gl.uniform1i(gl.getUniformLocation(m_po_aux, "texture_input"), 0);
4009 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i or glGetUniformLocation has failed");
4011 /* For each texture layer. */
4012 for (glw::GLuint i = 0; i < TestReferenceDataDepth<3>(); ++i)
4015 gl.drawBuffer(GL_COLOR_ATTACHMENT0 + i);
4016 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawBuffer has failed");
4018 gl.uniform1i(gl.getUniformLocation(m_po_aux, "texture_layer"), i);
4019 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i or glGetUniformLocation has failed");
4022 gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
4023 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays has failed");
4027 /** @brief Clean GL objects, test variables and GL errors.
4029 void StorageMultisampleTest::CleanInputTexture()
4031 /* Shortcut for GL functionality. */
4032 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4037 gl.deleteTextures(1, &m_to);
4043 /** @brief Clean GL objects, test variables and GL errors.
4045 void StorageMultisampleTest::CleanAuxiliaryTexture()
4047 /* Shortcut for GL functionality. */
4048 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4052 gl.deleteTextures(1, &m_to_aux);
4058 /** @brief Clean GL objects, test variables and GL errors.
4060 void StorageMultisampleTest::CleanFramebuffers()
4062 /* Shortcut for GL functionality. */
4063 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4065 /* Mulitsample framebuffer. */
4068 gl.deleteFramebuffers(1, &m_fbo_ms);
4073 /* Mulitsample texture. */
4076 gl.deleteTextures(1, &m_to_ms);
4081 /* Auxiliary framebuffer. */
4084 gl.deleteFramebuffers(1, &m_fbo_aux);
4089 /* Auxiliary texture. */
4092 gl.deleteTextures(1, &m_to_aux);
4098 /** @brief Clean GL objects, test variables and GL errors.
4100 void StorageMultisampleTest::CleanPrograms()
4102 /* Shortcut for GL functionality. */
4103 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4105 /* Binding point. */
4108 /* Multisample texture preparation program. */
4111 gl.deleteProgram(m_po_ms);
4116 /* Auxiliary texture preparation program. */
4119 gl.deleteProgram(m_po_aux);
4125 /** @brief Clean GL objects, test variables and GL errors.
4127 void StorageMultisampleTest::CleanErrors()
4129 /* Shortcut for GL functionality. */
4130 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4132 /* Query all errors until GL_NO_ERROR occure. */
4133 while (GL_NO_ERROR != gl.getError())
4137 /** @brief Clean GL objects, test variables and GL errors.
4139 void StorageMultisampleTest::CleanVertexArray()
4141 /* Shortcut for GL functionality. */
4142 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4146 gl.bindVertexArray(0);
4148 gl.deleteVertexArrays(1, &m_vao);
4154 /** @brief Iterate Storage Multisample Test cases.
4156 * @return Iteration result.
4158 tcu::TestNode::IterateResult StorageMultisampleTest::iterate()
4160 /* Shortcut for GL functionality. */
4161 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4163 /* Get context setup. */
4164 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
4165 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
4167 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
4169 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
4174 /* Running tests. */
4176 bool is_error = false;
4180 PrepareVertexArray();
4182 // gl.enable(GL_MULTISAMPLE);
4184 is_ok &= LoopTestOverDOverS<glw::GLbyte, false>(true);
4185 is_ok &= LoopTestOverDOverS<glw::GLubyte, false>(true);
4186 is_ok &= LoopTestOverDOverS<glw::GLshort, false>(true);
4187 is_ok &= LoopTestOverDOverS<glw::GLushort, false>(true);
4188 is_ok &= LoopTestOverDOverS<glw::GLint, false>(false);
4189 is_ok &= LoopTestOverDOverS<glw::GLuint, false>(false);
4190 is_ok &= LoopTestOverDOverS<glw::GLubyte, true>(true);
4191 is_ok &= LoopTestOverDOverS<glw::GLushort, true>(true);
4192 is_ok &= LoopTestOverDOverS<glw::GLfloat, true>(false);
4201 CleanInputTexture();
4202 CleanAuxiliaryTexture();
4203 CleanFramebuffers();
4207 gl.disable(GL_MULTISAMPLE);
4209 /* Errors clean up. */
4210 while (gl.getError())
4213 /* Result's setup. */
4216 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
4222 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
4226 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
4233 /* Vertex shader source code. */
4234 const glw::GLchar* StorageMultisampleTest::s_vertex_shader = "#version 450\n"
4238 " switch(gl_VertexID)\n"
4241 " gl_Position = vec4(-1.0, 1.0, 0.0, 1.0);\n"
4244 " gl_Position = vec4( 1.0, 1.0, 0.0, 1.0);\n"
4247 " gl_Position = vec4(-1.0,-1.0, 0.0, 1.0);\n"
4250 " gl_Position = vec4( 1.0,-1.0, 0.0, 1.0);\n"
4255 /* Fragment shader source program. */
4256 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_head =
4259 "layout(pixel_center_integer) in vec4 gl_FragCoord;\n"
4262 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_2D_fdecl_lowp =
4263 "uniform sampler2D texture_input;\nout vec4 texture_output;\n";
4264 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_2D_idecl_lowp =
4265 "uniform isampler2D texture_input;\nout ivec4 texture_output;\n";
4266 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_2D_udecl_lowp =
4267 "uniform usampler2D texture_input;\nout uvec4 texture_output;\n";
4268 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_2D_fdecl_mediump =
4269 "uniform sampler2D texture_input;\nout vec4 texture_output;\n";
4270 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_2D_idecl_mediump =
4271 "uniform isampler2D texture_input;\nout ivec4 texture_output;\n";
4272 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_2D_udecl_mediump =
4273 "uniform usampler2D texture_input;\nout uvec4 texture_output;\n";
4274 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_2D_fdecl_highp =
4275 "uniform sampler2D texture_input;\nout vec4 texture_output;\n";
4276 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_2D_idecl_highp =
4277 "uniform isampler2D texture_input;\nout ivec4 texture_output;\n";
4278 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_2D_udecl_highp =
4279 "uniform usampler2D texture_input;\nout uvec4 texture_output;\n";
4281 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_3D_fdecl_lowp =
4282 "uniform sampler2DArray texture_input;\nout vec4 texture_output;\n";
4284 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_3D_idecl_lowp =
4285 "uniform isampler2DArray texture_input;\nout ivec4 texture_output;\n";
4287 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_3D_udecl_lowp =
4288 "uniform usampler2DArray texture_input;\nout uvec4 texture_output;\n";
4290 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_3D_fdecl_mediump =
4291 "uniform sampler2DArray texture_input;\nout vec4 texture_output;\n";
4293 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_3D_idecl_mediump =
4294 "uniform isampler2DArray texture_input;\nout ivec4 texture_output;\n";
4296 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_3D_udecl_mediump =
4297 "uniform usampler2DArray texture_input;\nout uvec4 texture_output;\n";
4299 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_3D_fdecl_highp =
4300 "uniform sampler2DArray texture_input;\nout vec4 texture_output;\n";
4302 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_3D_idecl_highp =
4303 "uniform isampler2DArray texture_input;\nout ivec4 texture_output;\n";
4305 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_3D_udecl_highp =
4306 "uniform usampler2DArray texture_input;\nout uvec4 texture_output;\n";
4308 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_2D_fdecl_lowp =
4309 "uniform sampler2DMS texture_input;\nout vec4 texture_output;\n";
4310 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_2D_idecl_lowp =
4311 "uniform isampler2DMS texture_input;\nout ivec4 texture_output;\n";
4312 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_2D_udecl_lowp =
4313 "uniform usampler2DMS texture_input;\nout uvec4 texture_output;\n";
4315 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_2D_fdecl_mediump =
4316 "uniform sampler2DMS texture_input;\nout vec4 texture_output;\n";
4318 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_2D_idecl_mediump =
4319 "uniform isampler2DMS texture_input;\nout ivec4 texture_output;\n";
4321 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_2D_udecl_mediump =
4322 "uniform usampler2DMS texture_input;\nout uvec4 texture_output;\n";
4324 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_2D_fdecl_highp =
4325 "uniform sampler2DMS texture_input;\nout vec4 texture_output;\n";
4326 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_2D_idecl_highp =
4327 "uniform isampler2DMS texture_input;\nout ivec4 texture_output;\n";
4328 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_2D_udecl_highp =
4329 "uniform usampler2DMS texture_input;\nout uvec4 texture_output;\n";
4331 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_3D_fdecl_lowp =
4332 "uniform sampler2DMSArray texture_input;\nout vec4 texture_output;\n";
4334 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_3D_idecl_lowp =
4335 "uniform isampler2DMSArray texture_input;\nout ivec4 texture_output;\n";
4337 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_3D_udecl_lowp =
4338 "uniform usampler2DMSArray texture_input;\nout uvec4 texture_output;\n";
4340 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_3D_fdecl_mediump =
4341 "uniform sampler2DMSArray texture_input;\nout vec4 texture_output;\n";
4343 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_3D_idecl_mediump =
4344 "uniform isampler2DMSArray texture_input;\nout ivec4 texture_output;\n";
4346 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_3D_udecl_mediump =
4347 "uniform usampler2DMSArray texture_input;\nout uvec4 texture_output;\n";
4349 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_3D_fdecl_highp =
4350 "uniform sampler2DMSArray texture_input;\nout vec4 texture_output;\n";
4352 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_3D_idecl_highp =
4353 "uniform isampler2DMSArray texture_input;\nout ivec4 texture_output;\n";
4355 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_3D_udecl_highp =
4356 "uniform usampler2DMSArray texture_input;\nout uvec4 texture_output;\n";
4358 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_tail_2D =
4362 " texture_output = texelFetch(texture_input, ivec2(gl_FragCoord.xy), 0);\n"
4365 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_tail_3D =
4367 "uniform int texture_layer;\n"
4371 " texture_output = texelFetch(texture_input, ivec3(gl_FragCoord.xy, texture_layer), 0);\n"
4374 /******************************** Compressed SubImage Test Implementation ********************************/
4376 /** @brief Compressed SubImage Test constructor.
4378 * @param [in] context OpenGL context.
4380 CompressedSubImageTest::CompressedSubImageTest(deqp::Context& context)
4381 : deqp::TestCase(context, "textures_compressed_subimage", "Texture Compressed SubImage Test")
4384 , m_compressed_texture_data(DE_NULL)
4385 , m_reference(DE_NULL)
4387 , m_reference_size(0)
4388 , m_reference_internalformat(0)
4390 /* Intentionally left blank. */
4393 /** @brief Create texture.
4395 * @param [in] target Texture target.
4397 void CompressedSubImageTest::CreateTextures(glw::GLenum target)
4399 /* Shortcut for GL functionality. */
4400 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4402 /* Auxiliary texture (for content creation). */
4403 gl.genTextures(1, &m_to_aux);
4404 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
4406 gl.bindTexture(target, m_to_aux);
4407 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
4409 /* Test texture (for data upload). */
4410 gl.genTextures(1, &m_to);
4411 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
4413 gl.bindTexture(target, m_to);
4414 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
4417 /** @brief Texture target selector.
4419 * @tparam D Texture dimenisons.
4421 * @return Texture target.
4424 glw::GLenum CompressedSubImageTest::TextureTarget<1>()
4426 return GL_TEXTURE_1D;
4430 glw::GLenum CompressedSubImageTest::TextureTarget<2>()
4432 return GL_TEXTURE_2D;
4436 glw::GLenum CompressedSubImageTest::TextureTarget<3>()
4438 return GL_TEXTURE_2D_ARRAY;
4441 /** @brief Prepare texture data for the auxiliary texture.
4443 * @tparam D Texture dimenisons.
4445 * @note parameters as passed to texImage*
4448 void CompressedSubImageTest::TextureImage<1>(glw::GLint internalformat)
4450 /* Shortcut for GL functionality. */
4451 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4453 gl.texImage1D(TextureTarget<1>(), 0, internalformat, s_texture_width, 0, GL_RGBA, GL_UNSIGNED_BYTE, s_texture_data);
4454 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
4457 /** @brief Prepare texture data for the auxiliary texture.
4459 * @tparam D Texture dimenisons.
4461 * @note parameters as passed to texImage*
4464 void CompressedSubImageTest::TextureImage<2>(glw::GLint internalformat)
4466 /* Shortcut for GL functionality. */
4467 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4469 gl.texImage2D(TextureTarget<2>(), 0, internalformat, s_texture_width, s_texture_height, 0, GL_RGBA,
4470 GL_UNSIGNED_BYTE, s_texture_data);
4471 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
4474 /** @brief Prepare texture data for the auxiliary texture.
4476 * @tparam D Texture dimenisons.
4478 * @note parameters as passed to texImage*
4481 void CompressedSubImageTest::TextureImage<3>(glw::GLint internalformat)
4483 /* Shortcut for GL functionality. */
4484 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4486 gl.texImage3D(TextureTarget<3>(), 0, internalformat, s_texture_width, s_texture_height, s_texture_depth, 0, GL_RGBA,
4487 GL_UNSIGNED_BYTE, s_texture_data);
4488 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage3D has failed");
4491 /** @brief Prepare texture data for the auxiliary texture.
4493 * @tparam D Texture dimensions.
4495 * @note parameters as passed to compressedTexImage*
4498 void CompressedSubImageTest::CompressedTexImage<1>(glw::GLint internalformat)
4500 /* Shortcut for GL functionality. */
4501 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4503 gl.compressedTexImage1D(TextureTarget<1>(), 0, internalformat, s_texture_width, 0, m_reference_size,
4504 m_compressed_texture_data);
4505 GLU_EXPECT_NO_ERROR(gl.getError(), "glCompressedTexImage1D has failed");
4508 /** @brief Prepare texture data for the auxiliary texture.
4510 * @tparam D Texture dimensions.
4512 * @note parameters as passed to compressedTexImage*
4515 void CompressedSubImageTest::CompressedTexImage<2>(glw::GLint internalformat)
4517 /* Shortcut for GL functionality. */
4518 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4520 gl.compressedTexImage2D(TextureTarget<2>(), 0, internalformat, s_texture_width, s_texture_height, 0,
4521 m_reference_size, m_compressed_texture_data);
4522 GLU_EXPECT_NO_ERROR(gl.getError(), "glCompressedTexImage2D has failed");
4525 /** @brief Prepare texture data for the auxiliary texture.
4527 * @tparam D Texture dimensions.
4529 * @note parameters as passed to compressedTexImage*
4532 void CompressedSubImageTest::CompressedTexImage<3>(glw::GLint internalformat)
4534 /* Shortcut for GL functionality. */
4535 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4537 gl.compressedTexImage3D(TextureTarget<3>(), 0, internalformat, s_texture_width, s_texture_height, s_texture_depth,
4538 0, m_reference_size, m_compressed_texture_data);
4539 GLU_EXPECT_NO_ERROR(gl.getError(), "glCompressedTexImage3D has failed");
4542 /** @brief Prepare texture data for the compressed texture.
4544 * @tparam D Texture dimenisons.
4546 * @param [in] internalformat Texture internal format.
4548 * @return True if tested function succeeded, false otherwise.
4551 bool CompressedSubImageTest::CompressedTextureSubImage<1>(glw::GLint internalformat)
4553 /* Shortcut for GL functionality. */
4554 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4556 /* Load texture image with tested function. */
4557 if (m_reference_size)
4559 for (glw::GLuint block = 0; block < s_block_count; ++block)
4561 gl.compressedTextureSubImage1D(m_to, 0, s_texture_width * block, s_texture_width, internalformat,
4562 m_reference_size, m_compressed_texture_data);
4567 /* For 1D version there is no specific compressed texture internal format spcified in OpenGL 4.5 core profile documentation.
4568 Only implementation depended specific internalformats may provide this functionality. As a result there may be no reference data to be substituted.
4569 Due to this reason there is no use of CompressedTextureSubImage1D and particulary it cannot be tested. */
4576 if (GL_NO_ERROR != (error = gl.getError()))
4578 m_context.getTestContext().getLog()
4579 << tcu::TestLog::Message << "glCompressedTextureSubImage1D unexpectedly generated error "
4580 << glu::getErrorStr(error) << " during the test with internal format "
4581 << glu::getTextureFormatStr(internalformat) << ". Test fails." << tcu::TestLog::EndMessage;
4589 /** @brief Prepare texture data for the compressed texture.
4591 * @tparam D Texture dimenisons.
4593 * @param [in] internalformat Texture internal format.
4595 * @return True if tested function succeeded, false otherwise.
4598 bool CompressedSubImageTest::CompressedTextureSubImage<2>(glw::GLint internalformat)
4600 /* Shortcut for GL functionality. */
4601 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4603 for (glw::GLuint y = 0; y < s_block_2d_size_y; ++y)
4605 for (glw::GLuint x = 0; x < s_block_2d_size_x; ++x)
4607 /* Load texture image with tested function. */
4608 gl.compressedTextureSubImage2D(m_to, 0, s_texture_width * x, s_texture_height * y, s_texture_width,
4609 s_texture_height, internalformat, m_reference_size,
4610 m_compressed_texture_data);
4616 if (GL_NO_ERROR != (error = gl.getError()))
4618 m_context.getTestContext().getLog()
4619 << tcu::TestLog::Message << "glCompressedTextureSubImage2D unexpectedly generated error "
4620 << glu::getErrorStr(error) << " during the test with internal format "
4621 << glu::getTextureFormatStr(internalformat) << ". Test fails." << tcu::TestLog::EndMessage;
4629 /** @brief Prepare texture data for the compressed texture.
4631 * @tparam D Texture dimenisons.
4633 * @param [in] internalformat Texture internal format.
4635 * @return True if tested function succeeded, false otherwise.
4638 bool CompressedSubImageTest::CompressedTextureSubImage<3>(glw::GLint internalformat)
4640 /* Shortcut for GL functionality. */
4641 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4643 for (glw::GLuint z = 0; z < s_block_3d_size; ++z)
4645 for (glw::GLuint y = 0; y < s_block_3d_size; ++y)
4647 for (glw::GLuint x = 0; x < s_block_3d_size; ++x)
4649 /* Load texture image with tested function. */
4650 gl.compressedTextureSubImage3D(m_to, 0, s_texture_width * x, s_texture_height * y, s_texture_depth * z,
4651 s_texture_width, s_texture_height, s_texture_depth, internalformat,
4652 m_reference_size, m_compressed_texture_data);
4660 if (GL_NO_ERROR != (error = gl.getError()))
4662 m_context.getTestContext().getLog()
4663 << tcu::TestLog::Message << "glCompressedTextureSubImage2D unexpectedly generated error "
4664 << glu::getErrorStr(error) << " during the test with internal format "
4665 << glu::getTextureFormatStr(internalformat) << ". Test fails." << tcu::TestLog::EndMessage;
4672 /** @brief Prepare the reference data.
4674 * @tparam D Texture dimenisons.
4676 template <glw::GLuint D>
4677 void CompressedSubImageTest::PrepareReferenceData(glw::GLenum internalformat)
4679 /* Shortcut for GL functionality. */
4680 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4682 /* Using OpenGL to compress raw data. */
4683 gl.bindTexture(TextureTarget<D>(), m_to_aux);
4684 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
4686 TextureImage<D>(internalformat);
4688 /* Sanity checks. */
4689 if ((DE_NULL != m_reference) || (DE_NULL != m_compressed_texture_data))
4694 /* Check that really compressed texture. */
4695 glw::GLint is_compressed_texture = 0;
4696 gl.getTexLevelParameteriv(TextureTarget<D>(), 0, GL_TEXTURE_COMPRESSED, &is_compressed_texture);
4698 if (is_compressed_texture)
4700 /* Query texture size. */
4701 glw::GLint compressed_texture_size = 0;
4702 gl.getTexLevelParameteriv(TextureTarget<D>(), 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &compressed_texture_size);
4704 /* If compressed then download. */
4705 if (compressed_texture_size)
4707 /* Prepare storage. */
4708 m_compressed_texture_data = new glw::GLubyte[compressed_texture_size];
4710 if (DE_NULL != m_compressed_texture_data)
4712 m_reference_size = compressed_texture_size;
4719 /* Download the source compressed texture image. */
4720 gl.getCompressedTexImage(TextureTarget<D>(), 0, m_compressed_texture_data);
4721 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
4723 // Upload the source compressed texture image to the texture object.
4724 // Some compressed texture format can be emulated by the driver (like the ETC2/EAC formats)
4725 // The compressed data sent by CompressedTexImage will be stored uncompressed by the driver
4726 // and will be re-compressed if the application call glGetCompressedTexImage.
4727 // The compression/decompression is not lossless, so when this happen it's possible for the source
4728 // and destination (from glGetCompressedTexImage) compressed data to be different.
4729 // To avoid that we will store both the source (in m_compressed_texture_data) and the destination
4730 // (in m_reference). The destination will be used later to make sure getCompressedTextureSubImage
4731 // return the expected value
4732 CompressedTexImage<D>(internalformat);
4734 m_reference = new glw::GLubyte[m_reference_size];
4736 if (DE_NULL == m_reference)
4741 /* Download compressed texture image. */
4742 gl.getCompressedTexImage(TextureTarget<D>(), 0, m_reference);
4743 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
4748 /** @brief Prepare texture storage.
4750 * @tparam D Texture dimenisons.
4752 * @param [in] internalformat Texture internal format.
4755 void CompressedSubImageTest::PrepareStorage<1>(glw::GLenum internalformat)
4757 /* Shortcut for GL functionality. */
4758 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4760 gl.bindTexture(TextureTarget<1>(), m_to);
4761 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
4763 gl.texImage1D(TextureTarget<1>(), 0, internalformat, s_texture_width * s_block_count, 0, GL_RGBA, GL_UNSIGNED_BYTE,
4765 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
4768 /** @brief Prepare texture storage.
4770 * @tparam D Texture dimenisons.
4772 * @param [in] internalformat Texture internal format.
4775 void CompressedSubImageTest::PrepareStorage<2>(glw::GLenum internalformat)
4777 /* Shortcut for GL functionality. */
4778 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4780 gl.bindTexture(TextureTarget<2>(), m_to);
4781 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
4783 gl.texImage2D(TextureTarget<2>(), 0, internalformat, s_texture_width * s_block_2d_size_x,
4784 s_texture_height * s_block_2d_size_y, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
4785 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
4788 /** @brief Prepare texture storage.
4790 * @tparam D Texture dimenisons.
4792 * @param [in] internalformat Texture internal format.
4795 void CompressedSubImageTest::PrepareStorage<3>(glw::GLenum internalformat)
4797 /* Shortcut for GL functionality. */
4798 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4800 gl.bindTexture(TextureTarget<3>(), m_to);
4801 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
4803 gl.texImage3D(TextureTarget<3>(), 0, internalformat, s_texture_width * s_block_3d_size,
4804 s_texture_height * s_block_3d_size, s_texture_depth * s_block_3d_size, 0, GL_RGBA, GL_UNSIGNED_BYTE,
4806 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
4809 /** @brief Compare results with the reference.
4812 * @tparam S Size (# of components).
4813 * @tparam N Is normalized.
4815 * @param [in] internalformat Texture internal format.
4817 * @return True if equal, false otherwise.
4819 template <glw::GLuint D>
4820 bool CompressedSubImageTest::CheckData(glw::GLenum internalformat)
4822 /* Shortcut for GL functionality. */
4823 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4825 /* Check texture content with reference. */
4826 m_result = new glw::GLubyte[m_reference_size * s_block_count];
4828 if (DE_NULL == m_result)
4833 gl.getCompressedTexImage(TextureTarget<D>(), 0, m_result);
4834 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
4835 for (glw::GLuint block = 0; block < s_block_count; ++block)
4837 for (glw::GLuint i = 0; i < m_reference_size; ++i)
4839 if (m_reference[i] != m_result[block * m_reference_size + i])
4841 m_context.getTestContext().getLog()
4842 << tcu::TestLog::Message << "glCompressedTextureSubImage*D created texture with data "
4843 << DataToString(m_reference_size, m_reference) << " however texture contains data "
4844 << DataToString(m_reference_size, &(m_result[block * m_reference_size])) << ". Texture target was "
4845 << glu::getTextureTargetStr(TextureTarget<D>()) << " and internal format was "
4846 << glu::getTextureFormatStr(internalformat) << ". Test fails." << tcu::TestLog::EndMessage;
4856 /** @brief Compare results with the reference.
4859 * @tparam S Size (# of components).
4860 * @tparam N Is normalized.
4862 * @param [in] internalformat Texture internal format.
4864 * @return True if equal, false otherwise.
4867 bool CompressedSubImageTest::CheckData<3>(glw::GLenum internalformat)
4869 /* Shortcut for GL functionality. */
4870 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4872 /* Check texture content with reference. */
4873 m_result = new glw::GLubyte[m_reference_size * s_block_count];
4875 if (DE_NULL == m_result)
4880 gl.getCompressedTexImage(TextureTarget<3>(), 0, m_result);
4881 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
4883 glw::GLuint reference_layer_size = m_reference_size / s_texture_depth;
4885 for (glw::GLuint i = 0; i < m_reference_size * s_block_count; ++i)
4887 // we will read the result one bytes at the time and compare with the reference
4888 // for each bytes of the result image we need to figure out which byte in the reference image it corresponds to
4889 glw::GLuint refIdx = i % reference_layer_size;
4890 glw::GLuint refLayerIdx = (i / (reference_layer_size * s_block_3d_size * s_block_3d_size)) % s_texture_depth;
4891 if (m_reference[refLayerIdx * reference_layer_size + refIdx] != m_result[i])
4893 m_context.getTestContext().getLog()
4894 << tcu::TestLog::Message << "glCompressedTextureSubImage3D created texture with data "
4895 << DataToString(reference_layer_size, &(m_reference[refLayerIdx * reference_layer_size]))
4896 << " however texture contains data "
4897 << DataToString(reference_layer_size, &(m_result[i % reference_layer_size])) << ". Texture target was "
4898 << glu::getTextureTargetStr(TextureTarget<3>()) << " and internal format was "
4899 << glu::getTextureFormatStr(internalformat) << ". Test fails." << tcu::TestLog::EndMessage;
4907 /** @brief Test case function.
4909 * @tparam D Number of texture dimensions.
4911 * @param [in] internal format Texture internal format.
4913 * @return True if test succeeded, false otherwise.
4915 template <glw::GLuint D>
4916 bool CompressedSubImageTest::Test(glw::GLenum internalformat)
4918 /* Create texture image. */
4919 CreateTextures(TextureTarget<D>());
4920 PrepareReferenceData<D>(internalformat);
4921 PrepareStorage<D>(internalformat);
4923 /* Setup data with CompressedTextureSubImage<D>D function and check for errors. */
4924 if (!CompressedTextureSubImage<D>(internalformat))
4931 /* If compressed reference data was generated than compare values. */
4934 if (!CheckData<D>(internalformat))
4947 /** @brief Clean GL objects, test variables and GL errors.
4949 void CompressedSubImageTest::CleanAll()
4951 /* Shortcut for GL functionality. */
4952 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4957 gl.deleteTextures(1, &m_to);
4964 gl.deleteTextures(1, &m_to_aux);
4969 /* Reference data storage. */
4970 if (DE_NULL != m_reference)
4972 delete[] m_reference;
4974 m_reference = DE_NULL;
4977 if (DE_NULL != m_compressed_texture_data)
4979 delete[] m_compressed_texture_data;
4981 m_compressed_texture_data = DE_NULL;
4984 if (DE_NULL != m_result)
4991 m_reference_size = 0;
4994 while (GL_NO_ERROR != gl.getError())
4998 /** @brief Convert raw data into string for logging purposes.
5000 * @param [in] count Count of the data.
5001 * @param [in] data Raw data.
5003 * @return String representation of data.
5005 std::string CompressedSubImageTest::DataToString(glw::GLuint count, const glw::GLubyte data[])
5007 std::string data_str = "[";
5009 for (glw::GLuint i = 0; i < count; ++i)
5011 std::stringstream int_sstream;
5013 int_sstream << unsigned(data[i]);
5015 data_str.append(int_sstream.str());
5019 data_str.append(", ");
5023 data_str.append("]");
5030 /** @brief Iterate Compressed SubImage Test cases.
5032 * @return Iteration result.
5034 tcu::TestNode::IterateResult CompressedSubImageTest::iterate()
5036 /* Shortcut for GL functionality. */
5037 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5039 /* Get context setup. */
5040 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
5041 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
5043 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
5045 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
5050 /* Running tests. */
5052 bool is_error = false;
5056 is_ok &= Test<1>(GL_COMPRESSED_RGB);
5058 is_ok &= Test<2>(GL_COMPRESSED_RED_RGTC1);
5059 is_ok &= Test<2>(GL_COMPRESSED_SIGNED_RED_RGTC1);
5060 is_ok &= Test<2>(GL_COMPRESSED_RG_RGTC2);
5061 is_ok &= Test<2>(GL_COMPRESSED_SIGNED_RG_RGTC2);
5062 is_ok &= Test<2>(GL_COMPRESSED_RGBA_BPTC_UNORM);
5063 is_ok &= Test<2>(GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM);
5064 is_ok &= Test<2>(GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT);
5065 is_ok &= Test<2>(GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT);
5066 is_ok &= Test<2>(GL_COMPRESSED_RGB8_ETC2);
5067 is_ok &= Test<2>(GL_COMPRESSED_SRGB8_ETC2);
5068 is_ok &= Test<2>(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2);
5069 is_ok &= Test<2>(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2);
5070 is_ok &= Test<2>(GL_COMPRESSED_RGBA8_ETC2_EAC);
5071 is_ok &= Test<2>(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC);
5072 is_ok &= Test<2>(GL_COMPRESSED_R11_EAC);
5073 is_ok &= Test<2>(GL_COMPRESSED_SIGNED_R11_EAC);
5074 is_ok &= Test<2>(GL_COMPRESSED_RG11_EAC);
5075 is_ok &= Test<2>(GL_COMPRESSED_SIGNED_RG11_EAC);
5077 is_ok &= Test<3>(GL_COMPRESSED_RED_RGTC1);
5078 is_ok &= Test<3>(GL_COMPRESSED_SIGNED_RED_RGTC1);
5079 is_ok &= Test<3>(GL_COMPRESSED_RG_RGTC2);
5080 is_ok &= Test<3>(GL_COMPRESSED_SIGNED_RG_RGTC2);
5081 is_ok &= Test<3>(GL_COMPRESSED_RGBA_BPTC_UNORM);
5082 is_ok &= Test<3>(GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM);
5083 is_ok &= Test<3>(GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT);
5084 is_ok &= Test<3>(GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT);
5085 is_ok &= Test<3>(GL_COMPRESSED_RGB8_ETC2);
5086 is_ok &= Test<3>(GL_COMPRESSED_SRGB8_ETC2);
5087 is_ok &= Test<3>(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2);
5088 is_ok &= Test<3>(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2);
5089 is_ok &= Test<3>(GL_COMPRESSED_RGBA8_ETC2_EAC);
5090 is_ok &= Test<3>(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC);
5091 is_ok &= Test<3>(GL_COMPRESSED_R11_EAC);
5092 is_ok &= Test<3>(GL_COMPRESSED_SIGNED_R11_EAC);
5093 is_ok &= Test<3>(GL_COMPRESSED_RG11_EAC);
5094 is_ok &= Test<3>(GL_COMPRESSED_SIGNED_RG11_EAC);
5105 /* Errors clean up. */
5106 while (gl.getError())
5109 /* Result's setup. */
5112 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
5118 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
5122 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
5129 /** Reference data. */
5130 const glw::GLubyte CompressedSubImageTest::s_texture_data[] = {
5131 0x00, 0x00, 0x00, 0xFF, 0x7f, 0x7f, 0x7f, 0x00, 0xc3, 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0x00,
5132 0x88, 0x00, 0x15, 0xFF, 0xed, 0x1c, 0x24, 0x00, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x00, 0x00,
5133 0xc8, 0xbf, 0xe7, 0xFF, 0x70, 0x92, 0xbe, 0x00, 0x99, 0xd9, 0xea, 0xff, 0xb5, 0xe6, 0x1d, 0x00,
5134 0xa3, 0x49, 0xa4, 0xFF, 0x3f, 0x48, 0xcc, 0x00, 0x00, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0x00,
5136 0xa3, 0x49, 0xa4, 0xFF, 0xc8, 0xbf, 0xe7, 0x00, 0x88, 0x00, 0x15, 0xff, 0x00, 0x00, 0x00, 0x00,
5137 0x3f, 0x48, 0xcc, 0xFF, 0x70, 0x92, 0xbe, 0x00, 0xed, 0x1c, 0x24, 0xff, 0x7f, 0x7f, 0x7f, 0x00,
5138 0x00, 0xa2, 0xe8, 0xFF, 0x99, 0xd9, 0xea, 0x00, 0xff, 0x7f, 0x27, 0xff, 0xc3, 0xc3, 0xc3, 0x00,
5139 0x22, 0xb1, 0x4c, 0xFF, 0xb5, 0xe6, 0x1d, 0x00, 0xff, 0xf2, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00,
5141 0x22, 0xb1, 0x4c, 0xFF, 0x00, 0xa2, 0xe8, 0x00, 0x3f, 0x48, 0xcc, 0xff, 0xa3, 0x49, 0xa4, 0x00,
5142 0xb5, 0xe6, 0x1d, 0xFF, 0x99, 0xd9, 0xea, 0x00, 0x70, 0x92, 0xbe, 0xff, 0xc8, 0xbf, 0xe7, 0x00,
5143 0xff, 0xf2, 0x00, 0xFF, 0xff, 0x7f, 0x27, 0x00, 0xed, 0x1c, 0x24, 0xff, 0x88, 0x00, 0x15, 0x00,
5144 0xff, 0xff, 0xff, 0xFF, 0xc3, 0xc3, 0xc3, 0x00, 0x7f, 0x7f, 0x7f, 0xff, 0x00, 0x00, 0x00, 0x00,
5146 0xff, 0xff, 0xff, 0xFF, 0xff, 0xf2, 0x00, 0x00, 0xb5, 0xe6, 0x1d, 0xff, 0x22, 0xb1, 0x4c, 0x00,
5147 0xc3, 0xc3, 0xc3, 0xFF, 0xff, 0x7f, 0x27, 0x00, 0x99, 0xd9, 0xea, 0xff, 0x00, 0xa2, 0xe8, 0x00,
5148 0x7f, 0x7f, 0x7f, 0xFF, 0xed, 0x1c, 0x24, 0x00, 0x70, 0x92, 0xbe, 0xff, 0x3f, 0x48, 0xcc, 0x00,
5149 0x00, 0x00, 0x00, 0xFF, 0x88, 0x00, 0x15, 0x00, 0xc8, 0xbf, 0xe7, 0xff, 0xa3, 0x49, 0xa4, 0x00
5152 /** Reference data parameters. */
5153 const glw::GLuint CompressedSubImageTest::s_texture_width = 4;
5154 const glw::GLuint CompressedSubImageTest::s_texture_height = 4;
5155 const glw::GLuint CompressedSubImageTest::s_texture_depth = 4;
5156 const glw::GLuint CompressedSubImageTest::s_block_count = 8;
5157 const glw::GLuint CompressedSubImageTest::s_block_2d_size_x = 4;
5158 const glw::GLuint CompressedSubImageTest::s_block_2d_size_y = 2;
5159 const glw::GLuint CompressedSubImageTest::s_block_3d_size = 2;
5161 /******************************** Copy SubImage Test Implementation ********************************/
5163 /** @brief Compressed SubImage Test constructor.
5165 * @param [in] context OpenGL context.
5167 CopyTest::CopyTest(deqp::Context& context)
5168 : deqp::TestCase(context, "textures_copy", "Texture Copy Test")
5174 /* Intentionally left blank. */
5177 /** @brief Texture target selector.
5179 * @tparam D Texture dimenisons.
5181 * @return Texture target.
5184 glw::GLenum CopyTest::TextureTarget<1>()
5186 return GL_TEXTURE_1D;
5189 glw::GLenum CopyTest::TextureTarget<2>()
5191 return GL_TEXTURE_2D;
5194 glw::GLenum CopyTest::TextureTarget<3>()
5196 return GL_TEXTURE_3D;
5199 /** @brief Copy texture, check errors and log.
5201 * @note Parameters as passed to CopyTextureSubImage*D
5203 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
5205 bool CopyTest::CopyTextureSubImage1DAndCheckErrors(glw::GLuint texture, glw::GLint level, glw::GLint xoffset,
5206 glw::GLint x, glw::GLint y, glw::GLsizei width)
5208 /* Shortcut for GL functionality. */
5209 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5211 gl.readBuffer(GL_COLOR_ATTACHMENT0);
5212 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
5214 gl.copyTextureSubImage1D(texture, level, xoffset, x, y, width);
5219 if (GL_NO_ERROR != (error = gl.getError()))
5221 m_context.getTestContext().getLog() << tcu::TestLog::Message
5222 << "glCopyTextureSubImage1D unexpectedly generated error "
5223 << glu::getErrorStr(error) << ". Test fails." << tcu::TestLog::EndMessage;
5231 /** @brief Copy texture, check errors and log.
5233 * @note Parameters as passed to CopyTextureSubImage*D
5235 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
5237 bool CopyTest::CopyTextureSubImage2DAndCheckErrors(glw::GLuint texture, glw::GLint level, glw::GLint xoffset,
5238 glw::GLint yoffset, glw::GLint x, glw::GLint y, glw::GLsizei width,
5239 glw::GLsizei height)
5241 /* Shortcut for GL functionality. */
5242 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5244 gl.readBuffer(GL_COLOR_ATTACHMENT0);
5245 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
5247 gl.copyTextureSubImage2D(texture, level, xoffset, yoffset, x, y, width, height);
5252 if (GL_NO_ERROR != (error = gl.getError()))
5254 m_context.getTestContext().getLog() << tcu::TestLog::Message
5255 << "glCopyTextureSubImage2D unexpectedly generated error "
5256 << glu::getErrorStr(error) << ". Test fails." << tcu::TestLog::EndMessage;
5264 /** @brief Copy texture, check errors and log.
5266 * @note Parameters as passed to CopyTextureSubImage*D
5268 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
5270 bool CopyTest::CopyTextureSubImage3DAndCheckErrors(glw::GLuint texture, glw::GLint level, glw::GLint xoffset,
5271 glw::GLint yoffset, glw::GLint zoffset, glw::GLint x, glw::GLint y,
5272 glw::GLsizei width, glw::GLsizei height)
5274 /* Shortcut for GL functionality. */
5275 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5277 gl.readBuffer(GL_COLOR_ATTACHMENT0 + zoffset);
5278 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
5280 gl.copyTextureSubImage3D(texture, level, xoffset, yoffset, zoffset, x, y, width, height);
5285 if (GL_NO_ERROR != (error = gl.getError()))
5287 m_context.getTestContext().getLog() << tcu::TestLog::Message
5288 << "glCopyTextureSubImage3D unexpectedly generated error "
5289 << glu::getErrorStr(error) << ". Test fails." << tcu::TestLog::EndMessage;
5297 /** @brief Create texture.
5299 * @tparam D Dimmensions.
5302 void CopyTest::CreateSourceTexture<1>()
5304 /* Shortcut for GL functionality. */
5305 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5307 gl.genTextures(1, &m_to_src);
5308 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
5310 gl.bindTexture(TextureTarget<1>(), m_to_src);
5311 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
5313 gl.texImage1D(TextureTarget<1>(), 0, GL_RGBA8, s_texture_width, 0, GL_RGBA, GL_UNSIGNED_BYTE, s_texture_data);
5314 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D call failed.");
5317 /** @brief Create texture.
5319 * @tparam D Dimmensions.
5322 void CopyTest::CreateSourceTexture<2>()
5324 /* Shortcut for GL functionality. */
5325 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5327 gl.genTextures(1, &m_to_src);
5328 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
5330 gl.bindTexture(TextureTarget<2>(), m_to_src);
5331 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
5333 gl.texImage2D(TextureTarget<2>(), 0, GL_RGBA8, s_texture_width, s_texture_height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
5335 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D call failed.");
5338 /** @brief Create texture.
5340 * @tparam D Dimmensions.
5343 void CopyTest::CreateSourceTexture<3>()
5345 /* Shortcut for GL functionality. */
5346 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5348 gl.genTextures(1, &m_to_src);
5349 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
5351 gl.bindTexture(TextureTarget<3>(), m_to_src);
5352 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
5354 gl.texImage3D(TextureTarget<3>(), 0, GL_RGBA8, s_texture_width, s_texture_height, s_texture_depth, 0, GL_RGBA,
5355 GL_UNSIGNED_BYTE, s_texture_data);
5356 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D call failed.");
5359 /** @brief Create texture.
5361 * @tparam D Dimmensions.
5364 void CopyTest::CreateDestinationTexture<1>()
5366 /* Shortcut for GL functionality. */
5367 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5369 gl.genTextures(1, &m_to_dst);
5370 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
5372 gl.bindTexture(TextureTarget<1>(), m_to_dst);
5373 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
5375 gl.texImage1D(TextureTarget<1>(), 0, GL_RGBA8, s_texture_width, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL);
5376 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D call failed.");
5379 /** @brief Create texture.
5381 * @tparam D Dimmensions.
5384 void CopyTest::CreateDestinationTexture<2>()
5386 /* Shortcut for GL functionality. */
5387 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5389 gl.genTextures(1, &m_to_dst);
5390 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
5392 gl.bindTexture(TextureTarget<2>(), m_to_dst);
5393 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
5395 gl.texImage2D(TextureTarget<2>(), 0, GL_RGBA8, s_texture_width, s_texture_height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
5397 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D call failed.");
5400 /** @brief Create texture.
5402 * @tparam D Dimmensions.
5405 void CopyTest::CreateDestinationTexture<3>()
5407 /* Shortcut for GL functionality. */
5408 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5410 gl.genTextures(1, &m_to_dst);
5411 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
5413 gl.bindTexture(TextureTarget<3>(), m_to_dst);
5414 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
5416 gl.texImage3D(TextureTarget<3>(), 0, GL_RGBA8, s_texture_width, s_texture_height, s_texture_depth, 0, GL_RGBA,
5417 GL_UNSIGNED_BYTE, DE_NULL);
5418 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D call failed.");
5421 /** @brief Create framebuffer.
5423 * @tparam D Dimmensions.
5426 void CopyTest::CreateSourceFramebuffer<1>()
5428 /* Shortcut for GL functionality. */
5429 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5431 /* Prepare framebuffer. */
5432 gl.genFramebuffers(1, &m_fbo);
5433 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
5435 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
5436 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
5438 gl.framebufferTexture1D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, TextureTarget<1>(), m_to_src, 0);
5439 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferTexture1D call failed.");
5441 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
5446 gl.viewport(0, 0, s_texture_width, 1);
5447 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
5450 /** @brief Create framebuffer.
5452 * @tparam D Dimmensions.
5455 void CopyTest::CreateSourceFramebuffer<2>()
5457 /* Shortcut for GL functionality. */
5458 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5460 /* Prepare framebuffer. */
5461 gl.genFramebuffers(1, &m_fbo);
5462 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
5464 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
5465 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
5467 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, TextureTarget<2>(), m_to_src, 0);
5468 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferTexture1D call failed.");
5470 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
5475 gl.viewport(0, 0, s_texture_width, s_texture_height);
5476 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
5479 /** @brief Create framebuffer.
5481 * @tparam D Dimmensions.
5484 void CopyTest::CreateSourceFramebuffer<3>()
5486 /* Shortcut for GL functionality. */
5487 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5489 /* Prepare framebuffer. */
5490 gl.genFramebuffers(1, &m_fbo);
5491 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
5493 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
5494 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
5496 for (glw::GLuint i = 0; i < s_texture_depth; ++i)
5498 gl.framebufferTexture3D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, TextureTarget<3>(), m_to_src, 0, i);
5499 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferTexture1D call failed.");
5502 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
5507 gl.viewport(0, 0, s_texture_width, s_texture_height);
5508 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
5511 /** @brief Dispatch function to create test objects */
5512 template <glw::GLuint D>
5513 void CopyTest::CreateAll()
5515 CreateSourceTexture<D>();
5516 CreateSourceFramebuffer<D>();
5517 CreateDestinationTexture<D>();
5520 /** @brief Test function */
5522 bool CopyTest::Test<1>()
5528 result &= CopyTextureSubImage1DAndCheckErrors(m_to_dst, 0, 0, 0, 0, s_texture_width / 2);
5529 result &= CopyTextureSubImage1DAndCheckErrors(m_to_dst, 0, s_texture_width / 2, s_texture_width / 2, 0,
5530 s_texture_width / 2);
5532 result &= CheckData(TextureTarget<1>(), 4 /* RGBA */ * s_texture_width);
5539 /** @brief Test function */
5541 bool CopyTest::Test<2>()
5547 result &= CopyTextureSubImage2DAndCheckErrors(m_to_dst, 0, 0, 0, 0, 0, s_texture_width / 2, s_texture_height / 2);
5548 result &= CopyTextureSubImage2DAndCheckErrors(m_to_dst, 0, s_texture_width / 2, 0, s_texture_width / 2, 0,
5549 s_texture_width / 2, s_texture_height / 2);
5550 result &= CopyTextureSubImage2DAndCheckErrors(m_to_dst, 0, 0, s_texture_height / 2, 0, s_texture_height / 2,
5551 s_texture_width / 2, s_texture_height / 2);
5553 CopyTextureSubImage2DAndCheckErrors(m_to_dst, 0, s_texture_width / 2, s_texture_height / 2, s_texture_width / 2,
5554 s_texture_height / 2, s_texture_width / 2, s_texture_height / 2);
5556 result &= CheckData(TextureTarget<2>(), 4 /* RGBA */ * s_texture_width * s_texture_height);
5563 /** @brief Test function */
5565 bool CopyTest::Test<3>()
5571 for (glw::GLuint i = 0; i < s_texture_depth; ++i)
5574 CopyTextureSubImage3DAndCheckErrors(m_to_dst, 0, 0, 0, i, 0, 0, s_texture_width / 2, s_texture_height / 2);
5575 result &= CopyTextureSubImage3DAndCheckErrors(m_to_dst, 0, s_texture_width / 2, 0, i, s_texture_width / 2, 0,
5576 s_texture_width / 2, s_texture_height / 2);
5577 result &= CopyTextureSubImage3DAndCheckErrors(m_to_dst, 0, 0, s_texture_height / 2, i, 0, s_texture_height / 2,
5578 s_texture_width / 2, s_texture_height / 2);
5579 result &= CopyTextureSubImage3DAndCheckErrors(m_to_dst, 0, s_texture_width / 2, s_texture_height / 2, i,
5580 s_texture_width / 2, s_texture_height / 2, s_texture_width / 2,
5581 s_texture_height / 2);
5584 result &= CheckData(TextureTarget<3>(), 4 /* RGBA */ * s_texture_width * s_texture_height * s_texture_depth);
5591 /** @brief Compre results with the reference.
5593 * @param [in] target Texture target.
5594 * @param [in] size Size of the buffer.
5596 * @return True if equal, false otherwise.
5598 bool CopyTest::CheckData(glw::GLenum target, glw::GLuint size)
5600 /* Shortcut for GL functionality. */
5601 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5603 /* Check texture content with reference. */
5604 m_result = new glw::GLubyte[size];
5606 if (DE_NULL == m_result)
5611 gl.getTexImage(target, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_result);
5612 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
5614 for (glw::GLuint i = 0; i < size; ++i)
5616 if (s_texture_data[i] != m_result[i])
5618 m_context.getTestContext().getLog()
5619 << tcu::TestLog::Message << "glCopyTextureSubImage*D created texture with data "
5620 << DataToString(size, s_texture_data) << " however texture contains data "
5621 << DataToString(size, m_result) << ". Texture target was " << glu::getTextureTargetStr(target)
5622 << ". Test fails." << tcu::TestLog::EndMessage;
5631 /** @brief Convert raw data into string for logging purposes.
5633 * @param [in] count Count of the data.
5634 * @param [in] data Raw data.
5636 * @return String representation of data.
5638 std::string CopyTest::DataToString(glw::GLuint count, const glw::GLubyte data[])
5640 std::string data_str = "[";
5642 for (glw::GLuint i = 0; i < count; ++i)
5644 std::stringstream int_sstream;
5646 int_sstream << unsigned(data[i]);
5648 data_str.append(int_sstream.str());
5652 data_str.append(", ");
5656 data_str.append("]");
5663 /** @brief Clean GL objects, test variables and GL errors.
5665 void CopyTest::CleanAll()
5667 /* Shortcut for GL functionality. */
5668 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5672 gl.deleteFramebuffers(1, &m_fbo);
5679 gl.deleteTextures(1, &m_to_src);
5686 gl.deleteTextures(1, &m_to_dst);
5691 if (DE_NULL == m_result)
5698 while (GL_NO_ERROR != gl.getError())
5702 /** @brief Iterate Copy Test cases.
5704 * @return Iteration result.
5706 tcu::TestNode::IterateResult CopyTest::iterate()
5708 /* Get context setup. */
5709 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
5710 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
5712 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
5714 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
5719 /* Running tests. */
5721 bool is_error = false;
5738 /* Result's setup. */
5741 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
5747 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
5751 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
5758 /** Reference data. */
5759 const glw::GLubyte CopyTest::s_texture_data[] = {
5760 0x00, 0x00, 0x00, 0xFF, 0x7f, 0x7f, 0x7f, 0x00, 0xc3, 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0x00,
5761 0x88, 0x00, 0x15, 0xFF, 0xed, 0x1c, 0x24, 0x00, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x00, 0x00,
5762 0xc8, 0xbf, 0xe7, 0xFF, 0x70, 0x92, 0xbe, 0x00, 0x99, 0xd9, 0xea, 0xff, 0xb5, 0xe6, 0x1d, 0x00,
5763 0xa3, 0x49, 0xa4, 0xFF, 0x3f, 0x48, 0xcc, 0x00, 0x00, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0x00,
5765 0xa3, 0x49, 0xa4, 0xFF, 0xc8, 0xbf, 0xe7, 0x00, 0x88, 0x00, 0x15, 0xff, 0x00, 0x00, 0x00, 0x00,
5766 0x3f, 0x48, 0xcc, 0xFF, 0x70, 0x92, 0xbe, 0x00, 0xed, 0x1c, 0x24, 0xff, 0x7f, 0x7f, 0x7f, 0x00,
5767 0x00, 0xa2, 0xe8, 0xFF, 0x99, 0xd9, 0xea, 0x00, 0xff, 0x7f, 0x27, 0xff, 0xc3, 0xc3, 0xc3, 0x00,
5768 0x22, 0xb1, 0x4c, 0xFF, 0xb5, 0xe6, 0x1d, 0x00, 0xff, 0xf2, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00,
5770 0x22, 0xb1, 0x4c, 0xFF, 0x00, 0xa2, 0xe8, 0x00, 0x3f, 0x48, 0xcc, 0xff, 0xa3, 0x49, 0xa4, 0x00,
5771 0xb5, 0xe6, 0x1d, 0xFF, 0x99, 0xd9, 0xea, 0x00, 0x70, 0x92, 0xbe, 0xff, 0xc8, 0xbf, 0xe7, 0x00,
5772 0xff, 0xf2, 0x00, 0xFF, 0xff, 0x7f, 0x27, 0x00, 0xed, 0x1c, 0x24, 0xff, 0x88, 0x00, 0x15, 0x00,
5773 0xff, 0xff, 0xff, 0xFF, 0xc3, 0xc3, 0xc3, 0x00, 0x7f, 0x7f, 0x7f, 0xff, 0x00, 0x00, 0x00, 0x00,
5775 0xff, 0xff, 0xff, 0xFF, 0xff, 0xf2, 0x00, 0x00, 0xb5, 0xe6, 0x1d, 0xff, 0x22, 0xb1, 0x4c, 0x00,
5776 0xc3, 0xc3, 0xc3, 0xFF, 0xff, 0x7f, 0x27, 0x00, 0x99, 0xd9, 0xea, 0xff, 0x00, 0xa2, 0xe8, 0x00,
5777 0x7f, 0x7f, 0x7f, 0xFF, 0xed, 0x1c, 0x24, 0x00, 0x70, 0x92, 0xbe, 0xff, 0x3f, 0x48, 0xcc, 0x00,
5778 0x00, 0x00, 0x00, 0xFF, 0x88, 0x00, 0x15, 0x00, 0xc8, 0xbf, 0xe7, 0xff, 0xa3, 0x49, 0xa4, 0x00
5781 /** Reference data parameters. */
5782 const glw::GLuint CopyTest::s_texture_width = 4;
5783 const glw::GLuint CopyTest::s_texture_height = 4;
5784 const glw::GLuint CopyTest::s_texture_depth = 4;
5786 /******************************** Get Set Parameter Test Implementation ********************************/
5788 /** @brief Get Set Parameter Test constructor.
5790 * @param [in] context OpenGL context.
5792 GetSetParameterTest::GetSetParameterTest(deqp::Context& context)
5793 : deqp::TestCase(context, "textures_get_set_parameter", "Texture Get Set Parameter Test")
5795 /* Intentionally left blank. */
5798 /** @brief Iterate Get Set Parameter Test cases.
5800 * @return Iteration result.
5802 tcu::TestNode::IterateResult GetSetParameterTest::iterate()
5804 /* Shortcut for GL functionality. */
5805 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5807 /* Get context setup. */
5808 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
5809 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
5811 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
5813 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
5818 /* Running tests. */
5820 bool is_error = false;
5823 glw::GLuint texture = 0;
5827 gl.genTextures(1, &texture);
5828 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
5830 gl.bindTexture(GL_TEXTURE_3D, texture);
5831 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
5834 glw::GLenum name = GL_DEPTH_STENCIL_TEXTURE_MODE;
5835 glw::GLint value_src = GL_DEPTH_COMPONENT;
5836 glw::GLint value_dst = 0;
5838 gl.textureParameteri(texture, name, value_src);
5839 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
5841 gl.getTextureParameteriv(texture, name, &value_dst);
5842 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
5844 is_ok &= CompareAndLog(value_src, value_dst, name);
5848 glw::GLenum name = GL_TEXTURE_BASE_LEVEL;
5849 glw::GLint value_src = 2;
5850 glw::GLint value_dst = 0;
5852 gl.textureParameteri(texture, name, value_src);
5853 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
5855 gl.getTextureParameteriv(texture, name, &value_dst);
5856 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
5858 is_ok &= CompareAndLog(value_src, value_dst, name);
5862 glw::GLenum name = GL_TEXTURE_BORDER_COLOR;
5863 glw::GLfloat value_src[4] = { 0.25, 0.5, 0.75, 1.0 };
5864 glw::GLfloat value_dst[4] = {};
5866 gl.textureParameterfv(texture, name, value_src);
5867 is_ok &= CheckErrorAndLog("glTextureParameterfv", name);
5869 gl.getTextureParameterfv(texture, name, value_dst);
5870 is_ok &= CheckErrorAndLog("glGetTextureParameterfv", name);
5872 is_ok &= CompareAndLog(value_src, value_dst, name);
5876 glw::GLenum name = GL_TEXTURE_BORDER_COLOR;
5877 glw::GLint value_src[4] = { 0, 64, -64, -32 };
5878 glw::GLint value_dst[4] = {};
5880 gl.textureParameterIiv(texture, name, value_src);
5881 is_ok &= CheckErrorAndLog("glTextureParameterIiv", name);
5883 gl.getTextureParameterIiv(texture, name, value_dst);
5884 is_ok &= CheckErrorAndLog("glGetTextureParameterIiv", name);
5886 is_ok &= CompareAndLog(value_src, value_dst, name);
5890 glw::GLenum name = GL_TEXTURE_BORDER_COLOR;
5891 glw::GLuint value_src[4] = { 0, 64, 128, 192 };
5892 glw::GLuint value_dst[4] = {};
5894 gl.textureParameterIuiv(texture, name, value_src);
5895 is_ok &= CheckErrorAndLog("glTextureParameterIuiv", name);
5897 gl.getTextureParameterIuiv(texture, name, value_dst);
5898 is_ok &= CheckErrorAndLog("glGetTextureParameterIuiv", name);
5900 is_ok &= CompareAndLog(value_src, value_dst, name);
5904 glw::GLenum name = GL_TEXTURE_COMPARE_FUNC;
5905 glw::GLint value_src = GL_LEQUAL;
5906 glw::GLint value_dst = 0;
5908 gl.textureParameteri(texture, name, value_src);
5909 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
5911 gl.getTextureParameteriv(texture, name, &value_dst);
5912 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
5914 is_ok &= CompareAndLog(value_src, value_dst, name);
5918 glw::GLenum name = GL_TEXTURE_COMPARE_MODE;
5919 glw::GLint value_src = GL_COMPARE_REF_TO_TEXTURE;
5920 glw::GLint value_dst = 0;
5922 gl.textureParameteri(texture, name, value_src);
5923 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
5925 gl.getTextureParameteriv(texture, name, &value_dst);
5926 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
5928 is_ok &= CompareAndLog(value_src, value_dst, name);
5932 glw::GLenum name = GL_TEXTURE_LOD_BIAS;
5933 glw::GLfloat value_src = -2.f;
5934 glw::GLfloat value_dst = 0.f;
5936 gl.textureParameterf(texture, name, value_src);
5937 is_ok &= CheckErrorAndLog("glTextureParameterf", name);
5939 gl.getTextureParameterfv(texture, name, &value_dst);
5940 is_ok &= CheckErrorAndLog("glGetTextureParameterfv", name);
5942 is_ok &= CompareAndLog(value_src, value_dst, name);
5946 glw::GLenum name = GL_TEXTURE_MIN_FILTER;
5947 glw::GLint value_src = GL_LINEAR_MIPMAP_NEAREST;
5948 glw::GLint value_dst = 0;
5950 gl.textureParameteri(texture, name, value_src);
5951 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
5953 gl.getTextureParameteriv(texture, name, &value_dst);
5954 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
5956 is_ok &= CompareAndLog(value_src, value_dst, name);
5960 glw::GLenum name = GL_TEXTURE_MAG_FILTER;
5961 glw::GLint value_src = GL_NEAREST;
5962 glw::GLint value_dst = 0;
5964 gl.textureParameteri(texture, name, value_src);
5965 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
5967 gl.getTextureParameteriv(texture, name, &value_dst);
5968 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
5970 is_ok &= CompareAndLog(value_src, value_dst, name);
5974 glw::GLenum name = GL_TEXTURE_MIN_LOD;
5975 glw::GLint value_src = -100;
5976 glw::GLint value_dst = 0;
5978 gl.textureParameteri(texture, name, value_src);
5979 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
5981 gl.getTextureParameteriv(texture, name, &value_dst);
5982 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
5984 is_ok &= CompareAndLog(value_src, value_dst, name);
5988 glw::GLenum name = GL_TEXTURE_MAX_LOD;
5989 glw::GLint value_src = 100;
5990 glw::GLint value_dst = 0;
5992 gl.textureParameteri(texture, name, value_src);
5993 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
5995 gl.getTextureParameteriv(texture, name, &value_dst);
5996 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
5998 is_ok &= CompareAndLog(value_src, value_dst, name);
6002 glw::GLenum name = GL_TEXTURE_MAX_LEVEL;
6003 glw::GLint value_src = 100;
6004 glw::GLint value_dst = 0;
6006 gl.textureParameteri(texture, name, value_src);
6007 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
6009 gl.getTextureParameteriv(texture, name, &value_dst);
6010 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
6012 is_ok &= CompareAndLog(value_src, value_dst, name);
6016 glw::GLenum name = GL_TEXTURE_SWIZZLE_R;
6017 glw::GLint value_src = GL_BLUE;
6018 glw::GLint value_dst = 0;
6020 gl.textureParameteri(texture, name, value_src);
6021 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
6023 gl.getTextureParameteriv(texture, name, &value_dst);
6024 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
6026 is_ok &= CompareAndLog(value_src, value_dst, name);
6030 glw::GLenum name = GL_TEXTURE_SWIZZLE_G;
6031 glw::GLint value_src = GL_ALPHA;
6032 glw::GLint value_dst = 0;
6034 gl.textureParameteri(texture, name, value_src);
6035 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
6037 gl.getTextureParameteriv(texture, name, &value_dst);
6038 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
6040 is_ok &= CompareAndLog(value_src, value_dst, name);
6044 glw::GLenum name = GL_TEXTURE_SWIZZLE_B;
6045 glw::GLint value_src = GL_RED;
6046 glw::GLint value_dst = 0;
6048 gl.textureParameteri(texture, name, value_src);
6049 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
6051 gl.getTextureParameteriv(texture, name, &value_dst);
6052 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
6054 is_ok &= CompareAndLog(value_src, value_dst, name);
6058 glw::GLenum name = GL_TEXTURE_SWIZZLE_A;
6059 glw::GLint value_src = GL_GREEN;
6060 glw::GLint value_dst = 0;
6062 gl.textureParameteri(texture, name, value_src);
6063 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
6065 gl.getTextureParameteriv(texture, name, &value_dst);
6066 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
6068 is_ok &= CompareAndLog(value_src, value_dst, name);
6072 glw::GLenum name = GL_TEXTURE_SWIZZLE_RGBA;
6073 glw::GLint value_src[4] = { GL_ZERO, GL_ONE, GL_ZERO, GL_ONE };
6074 glw::GLint value_dst[4] = {};
6076 gl.textureParameteriv(texture, name, value_src);
6077 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
6079 gl.getTextureParameteriv(texture, name, value_dst);
6080 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
6082 is_ok &= CompareAndLog(value_src, value_dst, name);
6086 glw::GLenum name = GL_TEXTURE_WRAP_S;
6087 glw::GLint value_src = GL_MIRROR_CLAMP_TO_EDGE;
6088 glw::GLint value_dst = 11;
6090 gl.textureParameteri(texture, name, value_src);
6091 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
6093 gl.getTextureParameteriv(texture, name, &value_dst);
6094 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
6096 is_ok &= CompareAndLog(value_src, value_dst, name);
6100 glw::GLenum name = GL_TEXTURE_WRAP_T;
6101 glw::GLint value_src = GL_CLAMP_TO_EDGE;
6102 glw::GLint value_dst = 11;
6104 gl.textureParameteri(texture, name, value_src);
6105 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
6107 gl.getTextureParameteriv(texture, name, &value_dst);
6108 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
6110 is_ok &= CompareAndLog(value_src, value_dst, name);
6114 glw::GLenum name = GL_TEXTURE_WRAP_R;
6115 glw::GLint value_src = GL_CLAMP_TO_EDGE;
6116 glw::GLint value_dst = 11;
6118 gl.textureParameteriv(texture, name, &value_src);
6119 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
6121 gl.getTextureParameteriv(texture, name, &value_dst);
6122 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
6124 is_ok &= CompareAndLog(value_src, value_dst, name);
6136 gl.deleteTextures(1, &texture);
6139 while (GL_NO_ERROR != gl.getError())
6142 /* Result's setup. */
6145 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
6151 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
6155 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
6162 /** @brief Check for errors and log.
6164 * @param [in] fname Name of the function (to be logged).
6165 * @param [in] pname Parameter name with which function was called.
6167 * @return True if no error, false otherwise.
6169 bool GetSetParameterTest::CheckErrorAndLog(const glw::GLchar* fname, glw::GLenum pname)
6171 /* Shortcut for GL functionality. */
6172 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
6177 if (GL_NO_ERROR != (error = gl.getError()))
6179 m_context.getTestContext().getLog() << tcu::TestLog::Message << fname << " unexpectedly generated error "
6180 << glu::getErrorStr(error) << " during test of pname "
6181 << glu::getTextureParameterStr(pname) << ". Test fails."
6182 << tcu::TestLog::EndMessage;
6190 /** @brief Compare queried value of parameter with the expected vale.
6192 * @param [in] value_src First value.
6193 * @param [in] value_dst Second value.
6194 * @param [in] pname Parameter name.
6196 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6198 bool GetSetParameterTest::CompareAndLog(glw::GLint value_src, glw::GLint value_dst, glw::GLenum pname)
6200 if (value_src != value_dst)
6202 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Queried value of pname "
6203 << glu::getTextureParameterStr(pname) << " is equal to " << value_dst
6204 << ", however " << value_src << " was expected. Test fails."
6205 << tcu::TestLog::EndMessage;
6213 /** @brief Compare queried value of parameter with the expected vale.
6215 * @param [in] value_src First value.
6216 * @param [in] value_dst Second value.
6217 * @param [in] pname Parameter name.
6219 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6221 bool GetSetParameterTest::CompareAndLog(glw::GLuint value_src, glw::GLuint value_dst, glw::GLenum pname)
6223 if (value_src != value_dst)
6225 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Queried value of pname "
6226 << glu::getTextureParameterStr(pname) << " is equal to " << value_dst
6227 << ", however " << value_src << " was expected. Test fails."
6228 << tcu::TestLog::EndMessage;
6236 /** @brief Compare queried value of parameter with the expected vale.
6238 * @param [in] value_src First value.
6239 * @param [in] value_dst Second value.
6240 * @param [in] pname Parameter name.
6242 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6244 bool GetSetParameterTest::CompareAndLog(glw::GLfloat value_src, glw::GLfloat value_dst, glw::GLenum pname)
6246 if (de::abs(value_src - value_dst) > 0.0125 /* Precision */)
6248 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Queried value of pname "
6249 << glu::getTextureParameterStr(pname) << " is equal to " << value_dst
6250 << ", however " << value_src << " was expected. Test fails."
6251 << tcu::TestLog::EndMessage;
6259 /** @brief Compare queried value of parameter with the expected vale.
6261 * @param [in] value_src First value.
6262 * @param [in] value_dst Second value.
6263 * @param [in] pname Parameter name.
6265 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6267 bool GetSetParameterTest::CompareAndLog(glw::GLint value_src[4], glw::GLint value_dst[4], glw::GLenum pname)
6269 if ((value_src[0] != value_dst[0]) || (value_src[1] != value_dst[1]) || (value_src[2] != value_dst[2]) ||
6270 (value_src[3] != value_dst[3]))
6272 m_context.getTestContext().getLog()
6273 << tcu::TestLog::Message << "Queried value of pname " << glu::getTextureParameterStr(pname)
6274 << " is equal to [" << value_dst[0] << ", " << value_dst[1] << ", " << value_dst[2] << ", " << value_dst[3]
6275 << "], however " << value_src[0] << ", " << value_src[1] << ", " << value_src[2] << ", " << value_src[3]
6276 << "] was expected. Test fails." << tcu::TestLog::EndMessage;
6284 /** @brief Compare queried value of parameter with the expected vale.
6286 * @param [in] value_src First value.
6287 * @param [in] value_dst Second value.
6288 * @param [in] pname Parameter name.
6290 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6292 bool GetSetParameterTest::CompareAndLog(glw::GLuint value_src[4], glw::GLuint value_dst[4], glw::GLenum pname)
6294 if ((value_src[0] != value_dst[0]) || (value_src[1] != value_dst[1]) || (value_src[2] != value_dst[2]) ||
6295 (value_src[3] != value_dst[3]))
6297 m_context.getTestContext().getLog()
6298 << tcu::TestLog::Message << "Queried value of pname " << glu::getTextureParameterStr(pname)
6299 << " is equal to [" << value_dst[0] << ", " << value_dst[1] << ", " << value_dst[2] << ", " << value_dst[3]
6300 << "], however " << value_src[0] << ", " << value_src[1] << ", " << value_src[2] << ", " << value_src[3]
6301 << "] was expected. Test fails." << tcu::TestLog::EndMessage;
6309 /** @brief Compare queried value of parameter with the expected vale.
6311 * @param [in] value_src First value.
6312 * @param [in] value_dst Second value.
6313 * @param [in] pname Parameter name.
6315 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6317 bool GetSetParameterTest::CompareAndLog(glw::GLfloat value_src[4], glw::GLfloat value_dst[4], glw::GLenum pname)
6319 if ((de::abs(value_src[0] - value_dst[0]) > 0.0125 /* Precision */) ||
6320 (de::abs(value_src[1] - value_dst[1]) > 0.0125 /* Precision */) ||
6321 (de::abs(value_src[2] - value_dst[2]) > 0.0125 /* Precision */) ||
6322 (de::abs(value_src[3] - value_dst[3]) > 0.0125 /* Precision */))
6324 m_context.getTestContext().getLog()
6325 << tcu::TestLog::Message << "Queried value of pname " << glu::getTextureParameterStr(pname)
6326 << " is equal to [" << value_dst[0] << ", " << value_dst[1] << ", " << value_dst[2] << ", " << value_dst[3]
6327 << "], however " << value_src[0] << ", " << value_src[1] << ", " << value_src[2] << ", " << value_src[3]
6328 << "] was expected. Test fails." << tcu::TestLog::EndMessage;
6336 /******************************** Defaults Test Implementation ********************************/
6338 /** @brief Defaults Test constructor.
6340 * @param [in] context OpenGL context.
6342 DefaultsTest::DefaultsTest(deqp::Context& context)
6343 : deqp::TestCase(context, "textures_defaults", "Texture Defaults Test")
6345 /* Intentionally left blank. */
6348 /** @brief Defaults Test cases.
6350 * @return Iteration result.
6352 tcu::TestNode::IterateResult DefaultsTest::iterate()
6354 /* Shortcut for GL functionality. */
6355 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
6357 /* Get context setup. */
6358 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
6359 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
6361 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
6363 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
6368 /* Running tests. */
6370 bool is_error = false;
6373 glw::GLuint texture = 0;
6377 gl.createTextures(GL_TEXTURE_3D, 1, &texture);
6378 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
6381 glw::GLenum name = GL_DEPTH_STENCIL_TEXTURE_MODE;
6382 glw::GLint value_ref = GL_DEPTH_COMPONENT;
6383 glw::GLint value_dst = 0;
6385 gl.getTextureParameteriv(texture, name, &value_dst);
6386 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6388 is_ok &= CompareAndLog(value_ref, value_dst, name);
6392 glw::GLenum name = GL_TEXTURE_BASE_LEVEL;
6393 glw::GLint value_ref = 0;
6394 glw::GLint value_dst = 1;
6396 gl.getTextureParameteriv(texture, name, &value_dst);
6397 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6399 is_ok &= CompareAndLog(value_ref, value_dst, name);
6403 glw::GLenum name = GL_TEXTURE_BORDER_COLOR;
6404 glw::GLfloat value_ref[4] = { 0.f, 0.f, 0.f, 0.f };
6405 glw::GLfloat value_dst[4] = {};
6407 gl.getTextureParameterfv(texture, name, value_dst);
6408 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6410 is_ok &= CompareAndLog(value_ref, value_dst, name);
6414 glw::GLenum name = GL_TEXTURE_COMPARE_FUNC;
6415 glw::GLint value_ref = GL_LEQUAL;
6416 glw::GLint value_dst = 0;
6418 gl.getTextureParameteriv(texture, name, &value_dst);
6419 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6421 is_ok &= CompareAndLog(value_ref, value_dst, name);
6425 glw::GLenum name = GL_TEXTURE_COMPARE_MODE;
6426 glw::GLint value_ref = GL_NONE;
6427 glw::GLint value_dst = 0;
6429 gl.getTextureParameteriv(texture, name, &value_dst);
6430 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6432 is_ok &= CompareAndLog(value_ref, value_dst, name);
6436 glw::GLenum name = GL_TEXTURE_LOD_BIAS;
6437 glw::GLfloat value_ref = 0.f;
6438 glw::GLfloat value_dst = 0.f;
6440 gl.getTextureParameterfv(texture, name, &value_dst);
6441 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6443 is_ok &= CompareAndLog(value_ref, value_dst, name);
6447 glw::GLenum name = GL_TEXTURE_MIN_FILTER;
6448 glw::GLint value_ref = GL_NEAREST_MIPMAP_LINEAR;
6449 glw::GLint value_dst = 0;
6451 gl.getTextureParameteriv(texture, name, &value_dst);
6452 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6454 is_ok &= CompareAndLog(value_ref, value_dst, name);
6458 glw::GLenum name = GL_TEXTURE_MAG_FILTER;
6459 glw::GLint value_ref = GL_LINEAR;
6460 glw::GLint value_dst = 0;
6462 gl.getTextureParameteriv(texture, name, &value_dst);
6463 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6465 is_ok &= CompareAndLog(value_ref, value_dst, name);
6469 glw::GLenum name = GL_TEXTURE_MIN_LOD;
6470 glw::GLint value_ref = -1000;
6471 glw::GLint value_dst = 0;
6473 gl.getTextureParameteriv(texture, name, &value_dst);
6474 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6476 is_ok &= CompareAndLog(value_ref, value_dst, name);
6480 glw::GLenum name = GL_TEXTURE_MAX_LOD;
6481 glw::GLint value_ref = 1000;
6482 glw::GLint value_dst = 0;
6484 gl.getTextureParameteriv(texture, name, &value_dst);
6485 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6487 is_ok &= CompareAndLog(value_ref, value_dst, name);
6491 glw::GLenum name = GL_TEXTURE_MAX_LEVEL;
6492 glw::GLint value_ref = 1000;
6493 glw::GLint value_dst = 0;
6495 gl.getTextureParameteriv(texture, name, &value_dst);
6496 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6498 is_ok &= CompareAndLog(value_ref, value_dst, name);
6502 glw::GLenum name = GL_TEXTURE_SWIZZLE_R;
6503 glw::GLint value_ref = GL_RED;
6504 glw::GLint value_dst = 0;
6506 gl.getTextureParameteriv(texture, name, &value_dst);
6507 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6509 is_ok &= CompareAndLog(value_ref, value_dst, name);
6513 glw::GLenum name = GL_TEXTURE_SWIZZLE_G;
6514 glw::GLint value_ref = GL_GREEN;
6515 glw::GLint value_dst = 0;
6517 gl.getTextureParameteriv(texture, name, &value_dst);
6518 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6520 is_ok &= CompareAndLog(value_ref, value_dst, name);
6524 glw::GLenum name = GL_TEXTURE_SWIZZLE_B;
6525 glw::GLint value_ref = GL_BLUE;
6526 glw::GLint value_dst = 0;
6528 gl.getTextureParameteriv(texture, name, &value_dst);
6529 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6531 is_ok &= CompareAndLog(value_ref, value_dst, name);
6535 glw::GLenum name = GL_TEXTURE_SWIZZLE_A;
6536 glw::GLint value_ref = GL_ALPHA;
6537 glw::GLint value_dst = 0;
6539 gl.getTextureParameteriv(texture, name, &value_dst);
6540 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6542 is_ok &= CompareAndLog(value_ref, value_dst, name);
6546 glw::GLenum name = GL_TEXTURE_WRAP_S;
6547 glw::GLint value_ref = GL_REPEAT;
6548 glw::GLint value_dst = 11;
6550 gl.getTextureParameteriv(texture, name, &value_dst);
6551 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6553 is_ok &= CompareAndLog(value_ref, value_dst, name);
6557 glw::GLenum name = GL_TEXTURE_WRAP_T;
6558 glw::GLint value_ref = GL_REPEAT;
6559 glw::GLint value_dst = 11;
6561 gl.getTextureParameteriv(texture, name, &value_dst);
6562 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6564 is_ok &= CompareAndLog(value_ref, value_dst, name);
6568 glw::GLenum name = GL_TEXTURE_WRAP_R;
6569 glw::GLint value_ref = GL_REPEAT;
6570 glw::GLint value_dst = 11;
6572 gl.getTextureParameteriv(texture, name, &value_dst);
6573 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6575 is_ok &= CompareAndLog(value_ref, value_dst, name);
6587 gl.deleteTextures(1, &texture);
6590 while (GL_NO_ERROR != gl.getError())
6593 /* Result's setup. */
6596 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
6602 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
6606 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
6613 /** @brief Compare queried value of parameter with the expected vale.
6615 * @param [in] value_src First value.
6616 * @param [in] value_dst Second value.
6617 * @param [in] pname Parameter name.
6619 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6621 bool DefaultsTest::CompareAndLog(glw::GLint value_ref, glw::GLint value_dst, glw::GLenum pname)
6623 if (value_ref != value_dst)
6625 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Queried value of pname "
6626 << glu::getTextureParameterStr(pname) << " is equal to " << value_dst
6627 << ", however " << value_ref << " was expected. Test fails."
6628 << tcu::TestLog::EndMessage;
6636 /** @brief Compare queried value of parameter with the expected vale.
6638 * @param [in] value_src First value.
6639 * @param [in] value_dst Second value.
6640 * @param [in] pname Parameter name.
6642 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6644 bool DefaultsTest::CompareAndLog(glw::GLuint value_ref, glw::GLuint value_dst, glw::GLenum pname)
6646 if (value_ref != value_dst)
6648 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Queried value of pname "
6649 << glu::getTextureParameterStr(pname) << " is equal to " << value_dst
6650 << ", however " << value_ref << " was expected. Test fails."
6651 << tcu::TestLog::EndMessage;
6659 /** @brief Compare queried value of parameter with the expected vale.
6661 * @param [in] value_src First value.
6662 * @param [in] value_dst Second value.
6663 * @param [in] pname Parameter name.
6665 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6667 bool DefaultsTest::CompareAndLog(glw::GLfloat value_ref, glw::GLfloat value_dst, glw::GLenum pname)
6669 if (de::abs(value_ref - value_dst) > 0.0125 /* Precision */)
6671 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Queried value of pname "
6672 << glu::getTextureParameterStr(pname) << " is equal to " << value_dst
6673 << ", however " << value_ref << " was expected. Test fails."
6674 << tcu::TestLog::EndMessage;
6682 /** @brief Compare queried value of parameter with the expected vale.
6684 * @param [in] value_src First value.
6685 * @param [in] value_dst Second value.
6686 * @param [in] pname Parameter name.
6688 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6690 bool DefaultsTest::CompareAndLog(glw::GLint value_ref[4], glw::GLint value_dst[4], glw::GLenum pname)
6692 if ((value_ref[0] != value_dst[0]) || (value_ref[1] != value_dst[1]) || (value_ref[2] != value_dst[2]) ||
6693 (value_ref[3] != value_dst[3]))
6695 m_context.getTestContext().getLog()
6696 << tcu::TestLog::Message << "Queried value of pname " << glu::getTextureParameterStr(pname)
6697 << " is equal to [" << value_dst[0] << ", " << value_dst[1] << ", " << value_dst[2] << ", " << value_dst[3]
6698 << "], however " << value_ref[0] << ", " << value_ref[1] << ", " << value_ref[2] << ", " << value_ref[3]
6699 << "] was expected. Test fails." << tcu::TestLog::EndMessage;
6707 /** @brief Compare queried value of parameter with the expected vale.
6709 * @param [in] value_src First value.
6710 * @param [in] value_dst Second value.
6711 * @param [in] pname Parameter name.
6713 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6715 bool DefaultsTest::CompareAndLog(glw::GLuint value_ref[4], glw::GLuint value_dst[4], glw::GLenum pname)
6717 if ((value_ref[0] != value_dst[0]) || (value_ref[1] != value_dst[1]) || (value_ref[2] != value_dst[2]) ||
6718 (value_ref[3] != value_dst[3]))
6720 m_context.getTestContext().getLog()
6721 << tcu::TestLog::Message << "Queried value of pname " << glu::getTextureParameterStr(pname)
6722 << " is equal to [" << value_dst[0] << ", " << value_dst[1] << ", " << value_dst[2] << ", " << value_dst[3]
6723 << "], however " << value_ref[0] << ", " << value_ref[1] << ", " << value_ref[2] << ", " << value_ref[3]
6724 << "] was expected. Test fails." << tcu::TestLog::EndMessage;
6732 /** @brief Compare queried value of parameter with the expected vale.
6734 * @param [in] value_src First value.
6735 * @param [in] value_dst Second value.
6736 * @param [in] pname Parameter name.
6738 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6740 bool DefaultsTest::CompareAndLog(glw::GLfloat value_ref[4], glw::GLfloat value_dst[4], glw::GLenum pname)
6742 if ((de::abs(value_ref[0] - value_dst[0]) > 0.0125 /* Precision */) ||
6743 (de::abs(value_ref[1] - value_dst[1]) > 0.0125 /* Precision */) ||
6744 (de::abs(value_ref[2] - value_dst[2]) > 0.0125 /* Precision */) ||
6745 (de::abs(value_ref[3] - value_dst[3]) > 0.0125 /* Precision */))
6747 m_context.getTestContext().getLog()
6748 << tcu::TestLog::Message << "Queried value of pname " << glu::getTextureParameterStr(pname)
6749 << " is equal to [" << value_dst[0] << ", " << value_dst[1] << ", " << value_dst[2] << ", " << value_dst[3]
6750 << "], however " << value_ref[0] << ", " << value_ref[1] << ", " << value_ref[2] << ", " << value_ref[3]
6751 << "] was expected. Test fails." << tcu::TestLog::EndMessage;
6759 /******************************** Generate Mipmap Test Implementation ********************************/
6761 /** @brief Generate Mipmap Test constructor.
6763 * @param [in] context OpenGL context.
6765 GenerateMipmapTest::GenerateMipmapTest(deqp::Context& context)
6766 : deqp::TestCase(context, "textures_generate_mipmaps", "Textures Generate Mipmap Test")
6768 /* Intentionally left blank. */
6771 /** @brief Generate Mipmap Test cases.
6773 * @return Iteration result.
6775 tcu::TestNode::IterateResult GenerateMipmapTest::iterate()
6777 /* Shortcut for GL functionality. */
6778 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
6780 /* Get context setup. */
6781 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
6782 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
6784 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
6786 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
6791 /* Running tests. */
6793 bool is_error = false;
6795 /* Texture and cpu results storage. */
6796 glw::GLuint texture = 0;
6797 glw::GLubyte* result = DE_NULL;
6801 /* Prepare texture. */
6802 gl.genTextures(1, &texture);
6803 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
6805 gl.bindTexture(GL_TEXTURE_1D, texture);
6806 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
6808 gl.texImage1D(GL_TEXTURE_1D, 0, GL_R8, s_texture_width, 0, GL_RED, GL_UNSIGNED_BYTE, s_texture_data);
6809 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
6811 /* Generate mipmaps with tested function. */
6812 gl.generateTextureMipmap(texture);
6814 glw::GLenum error = GL_NO_ERROR;
6816 if (GL_NO_ERROR != (error = gl.getError()))
6818 m_context.getTestContext().getLog()
6819 << tcu::TestLog::Message << "GenerateTextureMipmap unexpectedly generated error "
6820 << glu::getErrorStr(error) << ". Test fails." << tcu::TestLog::EndMessage;
6825 /* Continue only if mipmaps has been generated. */
6828 result = new glw::GLubyte[s_texture_width];
6830 if (DE_NULL == result)
6835 /* For each mipmap. */
6836 for (glw::GLuint i = 0, j = s_texture_width;
6837 i < s_texture_width_log - 1 /* Do not test single pixel mipmap. */; ++i, j /= 2)
6839 /* Check mipmap size. */
6840 glw::GLint mipmap_size = 0;
6842 gl.getTexLevelParameteriv(GL_TEXTURE_1D, i, GL_TEXTURE_WIDTH, &mipmap_size);
6843 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
6845 if (mipmap_size != (glw::GLint)j)
6847 m_context.getTestContext().getLog()
6848 << tcu::TestLog::Message
6849 << "GenerateTextureMipmap unexpectedly generated mipmap with improper size. Mipmap size is "
6850 << mipmap_size << ", but " << j << " was expected. Test fails." << tcu::TestLog::EndMessage;
6858 gl.getTexImage(GL_TEXTURE_1D, i, GL_RED, GL_UNSIGNED_BYTE, result);
6859 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexImage has failed");
6861 /* Make comparison. */
6862 for (glw::GLuint k = 0; k < j - 1; ++k)
6864 if (((glw::GLint)result[k + 1]) - ((glw::GLint)result[k]) < 0)
6866 m_context.getTestContext().getLog() << tcu::TestLog::Message
6867 << "GenerateTextureMipmap unexpectedly generated improper "
6868 "mipmap (not descending). Test fails."
6869 << tcu::TestLog::EndMessage;
6888 gl.deleteTextures(1, &texture);
6891 if (DE_NULL != result)
6896 while (GL_NO_ERROR != gl.getError())
6899 /* Result's setup. */
6902 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
6908 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
6912 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
6919 /** Reference data. */
6920 const glw::GLubyte GenerateMipmapTest::s_texture_data[] = {
6921 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
6922 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
6923 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
6924 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
6925 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
6926 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131,
6927 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153,
6928 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
6929 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197,
6930 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
6931 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241,
6932 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
6935 /** Reference data parameters. */
6936 const glw::GLuint GenerateMipmapTest::s_texture_width = 256;
6937 const glw::GLuint GenerateMipmapTest::s_texture_width_log = 8;
6939 /******************************** Bind Unit Test Implementation ********************************/
6941 /** @brief Bind Unit Test constructor.
6943 * @param [in] context OpenGL context.
6945 BindUnitTest::BindUnitTest(deqp::Context& context)
6946 : deqp::TestCase(context, "textures_bind_unit", "Textures Bind Unit Test")
6959 /** @brief Bind Unit Test cases.
6961 * @return Iteration result.
6963 tcu::TestNode::IterateResult BindUnitTest::iterate()
6965 /* Get context setup. */
6966 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
6967 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
6969 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
6971 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
6976 /* Running tests. */
6978 bool is_error = false;
6985 CreateVertexArray();
6998 /* Result's setup. */
7001 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
7007 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
7011 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
7018 /** @brief Create test program.
7020 void BindUnitTest::CreateProgram()
7022 /* Shortcut for GL functionality */
7023 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7027 glw::GLchar const* source;
7028 glw::GLenum const type;
7030 } shader[] = { { s_vertex_shader, GL_VERTEX_SHADER, 0 }, { s_fragment_shader, GL_FRAGMENT_SHADER, 0 } };
7032 glw::GLuint const shader_count = sizeof(shader) / sizeof(shader[0]);
7036 /* Create program. */
7037 m_po = gl.createProgram();
7038 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateProgram call failed.");
7040 /* Shader compilation. */
7042 for (glw::GLuint i = 0; i < shader_count; ++i)
7044 if (DE_NULL != shader[i].source)
7046 shader[i].id = gl.createShader(shader[i].type);
7048 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateShader call failed.");
7050 gl.attachShader(m_po, shader[i].id);
7052 GLU_EXPECT_NO_ERROR(gl.getError(), "glAttachShader call failed.");
7054 gl.shaderSource(shader[i].id, 1, &shader[i].source, NULL);
7056 GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource call failed.");
7058 gl.compileShader(shader[i].id);
7060 GLU_EXPECT_NO_ERROR(gl.getError(), "glCompileShader call failed.");
7062 glw::GLint status = GL_FALSE;
7064 gl.getShaderiv(shader[i].id, GL_COMPILE_STATUS, &status);
7065 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv call failed.");
7067 if (GL_FALSE == status)
7069 glw::GLint log_size = 0;
7070 gl.getShaderiv(shader[i].id, GL_INFO_LOG_LENGTH, &log_size);
7071 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv call failed.");
7073 glw::GLchar* log_text = new glw::GLchar[log_size];
7075 gl.getShaderInfoLog(shader[i].id, log_size, NULL, &log_text[0]);
7077 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Shader compilation has failed.\n"
7078 << "Shader type: " << glu::getShaderTypeStr(shader[i].type)
7080 << "Shader compilation error log:\n"
7082 << "Shader source code:\n"
7083 << shader[i].source << "\n"
7084 << tcu::TestLog::EndMessage;
7088 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderInfoLog call failed.");
7096 gl.linkProgram(m_po);
7098 GLU_EXPECT_NO_ERROR(gl.getError(), "glTransformFeedbackVaryings call failed.");
7100 glw::GLint status = GL_FALSE;
7102 gl.getProgramiv(m_po, GL_LINK_STATUS, &status);
7104 if (GL_TRUE == status)
7106 for (glw::GLuint i = 0; i < shader_count; ++i)
7110 gl.detachShader(m_po, shader[i].id);
7112 GLU_EXPECT_NO_ERROR(gl.getError(), "glDetachShader call failed.");
7118 glw::GLint log_size = 0;
7120 gl.getProgramiv(m_po, GL_INFO_LOG_LENGTH, &log_size);
7122 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramiv call failed.");
7124 glw::GLchar* log_text = new glw::GLchar[log_size];
7126 gl.getProgramInfoLog(m_po, log_size, NULL, &log_text[0]);
7128 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Program linkage has failed due to:\n"
7130 << tcu::TestLog::EndMessage;
7134 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramInfoLog call failed.");
7143 gl.deleteProgram(m_po);
7149 for (glw::GLuint i = 0; i < shader_count; ++i)
7151 if (0 != shader[i].id)
7153 gl.deleteShader(shader[i].id);
7165 /** @brief Create texture.
7167 void BindUnitTest::CreateTextures()
7169 /* Shortcut for GL functionality. */
7170 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7172 /* Prepare texture. */
7173 gl.genTextures(4, m_to);
7174 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
7176 /* Setup pixel sotre modes.*/
7177 gl.pixelStorei(GL_UNPACK_ALIGNMENT, sizeof(glw::GLubyte));
7178 GLU_EXPECT_NO_ERROR(gl.getError(), "glPixelStorei has failed");
7180 gl.pixelStorei(GL_PACK_ALIGNMENT, sizeof(glw::GLubyte));
7181 GLU_EXPECT_NO_ERROR(gl.getError(), "glPixelStorei has failed");
7184 gl.bindTexture(GL_TEXTURE_2D, m_to[0]);
7185 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
7187 gl.texImage2D(GL_TEXTURE_2D, 0, GL_R8, s_texture_width, s_texture_height, 0, GL_RED, GL_UNSIGNED_BYTE,
7189 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
7191 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
7192 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
7193 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri call failed.");
7195 /* Green texture. */
7196 gl.bindTexture(GL_TEXTURE_2D, m_to[1]);
7197 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
7199 gl.texImage2D(GL_TEXTURE_2D, 0, GL_R8, s_texture_width, s_texture_height, 0, GL_RED, GL_UNSIGNED_BYTE,
7201 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
7203 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
7204 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
7205 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri call failed.");
7208 gl.bindTexture(GL_TEXTURE_2D, m_to[2]);
7209 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
7211 gl.texImage2D(GL_TEXTURE_2D, 0, GL_R8, s_texture_width, s_texture_height, 0, GL_RED, GL_UNSIGNED_BYTE,
7213 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
7215 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
7216 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
7217 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri call failed.");
7219 /* Alpha texture. */
7220 gl.bindTexture(GL_TEXTURE_2D, m_to[3]);
7221 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
7223 gl.texImage2D(GL_TEXTURE_2D, 0, GL_R8, s_texture_width, s_texture_height, 0, GL_RED, GL_UNSIGNED_BYTE,
7225 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
7227 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
7228 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
7229 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri call failed.");
7232 /** @brief Create framebuffer.
7234 void BindUnitTest::CreateFrambuffer()
7236 /* Shortcut for GL functionality. */
7237 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7239 /* Prepare framebuffer. */
7240 gl.genFramebuffers(1, &m_fbo);
7241 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
7243 gl.genRenderbuffers(1, &m_rbo);
7244 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
7246 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
7247 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
7249 gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo);
7250 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
7252 gl.renderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, s_texture_width, s_texture_height);
7253 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage call failed.");
7255 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo);
7256 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer call failed.");
7258 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
7263 gl.viewport(0, 0, s_texture_width, s_texture_height);
7264 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
7266 /* Clear framebuffer's content. */
7267 gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
7268 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor call failed.");
7270 gl.clear(GL_COLOR_BUFFER_BIT);
7271 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear call failed.");
7274 /** @brief Create vertex array object.
7276 void BindUnitTest::CreateVertexArray()
7278 /* Shortcut for GL functionality. */
7279 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7281 gl.genVertexArrays(1, &m_vao);
7282 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays call has failed.");
7284 gl.bindVertexArray(m_vao);
7285 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray call has failed.");
7288 bool BindUnitTest::Draw()
7290 /* Shortcut for GL functionality. */
7291 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7293 /* Setup program. */
7294 gl.useProgram(m_po);
7295 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram call has failed.");
7297 /* Bind textures to proper units and setup program's samplers. */
7298 for (glw::GLuint i = 0; i < 4; ++i)
7300 /* Tested binding funcion. */
7301 gl.bindTextureUnit(i, m_to[i]);
7303 /* Check for errors. */
7304 glw::GLenum error = GL_NO_ERROR;
7306 if (GL_NO_ERROR != (error = gl.getError()))
7308 m_context.getTestContext().getLog()
7309 << tcu::TestLog::Message << "BindTextureUnit unexpectedly generated error " << glu::getErrorStr(error)
7310 << " when binding texture " << m_to[i] << " to texture unit " << i << ". Test fails."
7311 << tcu::TestLog::EndMessage;
7316 /* Sampler setup. */
7317 gl.uniform1i(gl.getUniformLocation(m_po, s_fragment_shader_samplers[i]), i);
7318 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation or glUniform1i call has failed.");
7322 gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
7323 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays call has failed.");
7328 /** @brief Compare results with reference.
7330 * @return True if equal, false otherwise.
7332 bool BindUnitTest::Check()
7334 /* Shortcut for GL functionality. */
7335 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7337 /* Setup storage for results. */
7338 m_result = new glw::GLubyte[s_texture_count_rgba];
7340 /* Setup pixel sotre modes.*/
7341 gl.pixelStorei(GL_UNPACK_ALIGNMENT, sizeof(glw::GLubyte));
7342 GLU_EXPECT_NO_ERROR(gl.getError(), "glPixelStorei has failed");
7344 gl.pixelStorei(GL_PACK_ALIGNMENT, sizeof(glw::GLubyte));
7345 GLU_EXPECT_NO_ERROR(gl.getError(), "glPixelStorei has failed");
7347 /* Query framebuffer's image. */
7348 gl.readPixels(0, 0, s_texture_width, s_texture_height, GL_RGBA, GL_UNSIGNED_BYTE, m_result);
7349 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays call has failed.");
7351 /* Compare values with reference. */
7352 for (glw::GLuint i = 0; i < s_texture_count_rgba; ++i)
7354 if (s_texture_data_rgba[i] != m_result[i])
7356 m_context.getTestContext().getLog()
7357 << tcu::TestLog::Message << "Framebuffer data " << DataToString(s_texture_count_rgba, m_result)
7358 << " does not match the reference values " << DataToString(s_texture_count_rgba, s_texture_data_rgba)
7359 << "." << tcu::TestLog::EndMessage;
7368 /** @brief Clean GL objects, test variables and GL errors.
7370 void BindUnitTest::CleanAll()
7372 /* Shortcut for GL functionality. */
7373 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7375 /* Release GL objects. */
7380 gl.deleteProgram(m_po);
7385 if (m_to[0] || m_to[1] || m_to[2] || m_to[3])
7387 gl.deleteTextures(4, m_to);
7397 gl.deleteFramebuffers(1, &m_fbo);
7404 gl.deleteRenderbuffers(1, &m_rbo);
7410 if (DE_NULL != m_result)
7415 /* Erros clean-up. */
7416 while (GL_NO_ERROR != gl.getError())
7420 /** @brief Convert raw data into string for logging purposes.
7422 * @param [in] count Count of the data.
7423 * @param [in] data Raw data.
7425 * @return String representation of data.
7427 std::string BindUnitTest::DataToString(glw::GLuint count, const glw::GLubyte data[])
7429 std::string data_str = "[";
7431 for (glw::GLuint i = 0; i < count; ++i)
7433 std::stringstream int_sstream;
7435 int_sstream << unsigned(data[i]);
7437 data_str.append(int_sstream.str());
7441 data_str.append(", ");
7445 data_str.append("]");
7452 /** Reference data and parameters. */
7453 const glw::GLubyte BindUnitTest::s_texture_data_r[] = { 0, 4, 8, 12, 16, 20 };
7454 const glw::GLubyte BindUnitTest::s_texture_data_g[] = { 1, 5, 9, 13, 17, 21 };
7455 const glw::GLubyte BindUnitTest::s_texture_data_b[] = { 2, 6, 10, 14, 18, 22 };
7456 const glw::GLubyte BindUnitTest::s_texture_data_a[] = { 3, 7, 11, 15, 19, 23 };
7457 const glw::GLubyte BindUnitTest::s_texture_data_rgba[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
7458 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 };
7459 const glw::GLuint BindUnitTest::s_texture_width = 2;
7460 const glw::GLuint BindUnitTest::s_texture_height = 3;
7461 const glw::GLuint BindUnitTest::s_texture_count_rgba = sizeof(s_texture_data_rgba) / sizeof(s_texture_data_rgba[0]);
7463 /* Vertex shader source code. */
7464 const glw::GLchar* BindUnitTest::s_vertex_shader = "#version 450\n"
7468 " switch(gl_VertexID)\n"
7471 " gl_Position = vec4(-1.0, 1.0, 0.0, 1.0);\n"
7474 " gl_Position = vec4( 1.0, 1.0, 0.0, 1.0);\n"
7477 " gl_Position = vec4(-1.0,-1.0, 0.0, 1.0);\n"
7480 " gl_Position = vec4( 1.0,-1.0, 0.0, 1.0);\n"
7485 /* Fragment shader source program. */
7486 const glw::GLchar* BindUnitTest::s_fragment_shader =
7489 "layout(pixel_center_integer) in vec4 gl_FragCoord;\n"
7491 "uniform sampler2D texture_input_r;\n"
7492 "uniform sampler2D texture_input_g;\n"
7493 "uniform sampler2D texture_input_b;\n"
7494 "uniform sampler2D texture_input_a;\n"
7496 "out vec4 color_output;\n"
7500 " color_output = vec4(texelFetch(texture_input_r, ivec2(gl_FragCoord.xy), 0).r,\n"
7501 " texelFetch(texture_input_g, ivec2(gl_FragCoord.xy), 0).r,\n"
7502 " texelFetch(texture_input_b, ivec2(gl_FragCoord.xy), 0).r,\n"
7503 " texelFetch(texture_input_a, ivec2(gl_FragCoord.xy), 0).r);\n"
7506 const glw::GLchar* BindUnitTest::s_fragment_shader_samplers[4] = { "texture_input_r", "texture_input_g",
7507 "texture_input_b", "texture_input_a" };
7509 /******************************** Get Image Test Implementation ********************************/
7511 /** @brief Get Image Test constructor.
7513 * @param [in] context OpenGL context.
7515 GetImageTest::GetImageTest(deqp::Context& context)
7516 : deqp::TestCase(context, "textures_get_image", "Textures Get Image Test")
7518 /* Intentionally left blank */
7521 /** Reference data. */
7522 const glw::GLubyte GetImageTest::s_texture_data[] = { 0x0, 0x0, 0x0, 0xff, 0x7f, 0x7f, 0x7f, 0xff, 0xc3, 0xc3, 0xc3,
7523 0xff, 0xff, 0xff, 0xff, 0xff, 0x88, 0x0, 0x15, 0xff, 0xed, 0x1c,
7524 0x24, 0xff, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x0, 0xff, 0xc8,
7525 0xbf, 0xe7, 0xff, 0x70, 0x92, 0xbe, 0xff, 0x99, 0xd9, 0xea, 0xff,
7526 0xb5, 0xe6, 0x1d, 0xff, 0xa3, 0x49, 0xa4, 0xff, 0x3f, 0x48, 0xcc,
7527 0xff, 0x0, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0xff };
7529 /** Reference data (compressed). */
7530 const glw::GLubyte GetImageTest::s_texture_data_compressed[] = { 0x90, 0x2b, 0x8f, 0x0f, 0xfe, 0x0f, 0x98, 0x99,
7531 0x99, 0x99, 0x59, 0x8f, 0x8c, 0xa6, 0xb7, 0x71 };
7533 /** Reference data parameters. */
7534 const glw::GLuint GetImageTest::s_texture_width = 4;
7535 const glw::GLuint GetImageTest::s_texture_height = 4;
7536 const glw::GLuint GetImageTest::s_texture_size = sizeof(s_texture_data);
7537 const glw::GLuint GetImageTest::s_texture_size_compressed = sizeof(s_texture_data_compressed);
7538 const glw::GLuint GetImageTest::s_texture_count = s_texture_size / sizeof(s_texture_data[0]);
7539 const glw::GLuint GetImageTest::s_texture_count_compressed =
7540 s_texture_size_compressed / sizeof(s_texture_data_compressed[0]);
7542 /** @brief Get Image Test cases.
7544 * @return Iteration result.
7546 tcu::TestNode::IterateResult GetImageTest::iterate()
7548 /* Shortcut for GL functionality. */
7549 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7551 /* Get context setup. */
7552 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
7553 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
7555 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
7557 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
7562 /* Running tests. */
7564 bool is_error = false;
7567 glw::GLuint texture = 0;
7568 glw::GLubyte result[s_texture_count] = {};
7569 glw::GLubyte result_compressed[s_texture_count_compressed] = {};
7573 /* Uncompressed case. */
7575 /* Texture initiation. */
7576 gl.genTextures(1, &texture);
7577 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
7579 gl.bindTexture(GL_TEXTURE_2D, texture);
7580 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
7582 gl.texImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, s_texture_width, s_texture_height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
7584 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
7586 /* Quering image with tested function. */
7587 gl.getTextureImage(texture, 0, GL_RGBA, GL_UNSIGNED_BYTE, sizeof(result), result);
7589 /* Check for errors. */
7590 glw::GLenum error = GL_NO_ERROR;
7592 if (GL_NO_ERROR != (error = gl.getError()))
7594 m_context.getTestContext().getLog()
7595 << tcu::TestLog::Message << "GetTextureImage unexpectedly generated error "
7596 << glu::getErrorStr(error) << ". Test fails." << tcu::TestLog::EndMessage;
7602 /* No error, so compare images. */
7603 for (glw::GLuint i = 0; i < s_texture_count; ++i)
7605 if (s_texture_data[i] != result[i])
7607 m_context.getTestContext().getLog() << tcu::TestLog::Message << "GetTextureImage returned "
7608 << DataToString(s_texture_count, result) << ", but "
7609 << DataToString(s_texture_count, s_texture_data)
7610 << " was expected. Test fails." << tcu::TestLog::EndMessage;
7620 /* Clean up texture .*/
7621 gl.deleteTextures(1, &texture);
7622 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
7626 /* Compressed case. */
7628 /* Texture initiation. */
7629 gl.genTextures(1, &texture);
7630 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
7632 gl.bindTexture(GL_TEXTURE_2D, texture);
7633 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
7635 gl.compressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_BPTC_UNORM, s_texture_width, s_texture_height,
7636 0, s_texture_size_compressed, s_texture_data_compressed);
7637 GLU_EXPECT_NO_ERROR(gl.getError(), "glCompressedTexImage2D has failed");
7639 /* Quering image with tested function. */
7640 gl.getCompressedTextureImage(texture, 0, s_texture_count_compressed * sizeof(result_compressed[0]),
7643 /* Check for errors. */
7644 glw::GLenum error = GL_NO_ERROR;
7646 if (GL_NO_ERROR != (error = gl.getError()))
7648 m_context.getTestContext().getLog()
7649 << tcu::TestLog::Message << "GetCompressedTextureImage unexpectedly generated error "
7650 << glu::getErrorStr(error) << ". Test fails." << tcu::TestLog::EndMessage;
7656 /* No error, so compare images. */
7657 for (glw::GLuint i = 0; i < s_texture_count_compressed; ++i)
7659 if (s_texture_data_compressed[i] != result_compressed[i])
7661 m_context.getTestContext().getLog()
7662 << tcu::TestLog::Message << "GetCompressedTextureImage returned "
7663 << DataToString(s_texture_count_compressed, result_compressed) << ", but "
7664 << DataToString(s_texture_count_compressed, s_texture_data_compressed)
7665 << " was expected. Test fails." << tcu::TestLog::EndMessage;
7684 gl.deleteTextures(1, &texture);
7687 /* Result's setup. */
7690 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
7696 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
7700 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
7707 /** @brief Convert raw data into string for logging purposes.
7709 * @param [in] count Count of the data.
7710 * @param [in] data Raw data.
7712 * @return String representation of data.
7714 std::string GetImageTest::DataToString(glw::GLuint count, const glw::GLubyte data[])
7716 std::string data_str = "[";
7718 for (glw::GLuint i = 0; i < count; ++i)
7720 std::stringstream int_sstream;
7722 int_sstream << unsigned(data[i]);
7724 data_str.append(int_sstream.str());
7728 data_str.append(", ");
7732 data_str.append("]");
7739 /******************************** Get Level Parameter Test Implementation ********************************/
7741 /** @brief Get Level Parameter Test constructor.
7743 * @param [in] context OpenGL context.
7745 GetLevelParameterTest::GetLevelParameterTest(deqp::Context& context)
7746 : deqp::TestCase(context, "textures_get_level_parameter", "Textures Get Level Parameter Test")
7748 /* Intentionally left blank */
7751 /** Reference data. */
7752 const glw::GLubyte GetLevelParameterTest::s_texture_data[] = {
7753 0x0, 0x0, 0x0, 0xff, 0x7f, 0x7f, 0x7f, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff,
7754 0x88, 0x0, 0x15, 0xff, 0xed, 0x1c, 0x24, 0xff, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x0, 0xff,
7755 0xc8, 0xbf, 0xe7, 0xff, 0x70, 0x92, 0xbe, 0xff, 0x99, 0xd9, 0xea, 0xff, 0xb5, 0xe6, 0x1d, 0xff,
7756 0xa3, 0x49, 0xa4, 0xff, 0x3f, 0x48, 0xcc, 0xff, 0x0, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0xff,
7758 0x0, 0x0, 0x0, 0xff, 0x7f, 0x7f, 0x7f, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff,
7759 0x88, 0x0, 0x15, 0xff, 0xed, 0x1c, 0x24, 0xff, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x0, 0xff,
7760 0xc8, 0xbf, 0xe7, 0xff, 0x70, 0x92, 0xbe, 0xff, 0x99, 0xd9, 0xea, 0xff, 0xb5, 0xe6, 0x1d, 0xff,
7761 0xa3, 0x49, 0xa4, 0xff, 0x3f, 0x48, 0xcc, 0xff, 0x0, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0xff,
7763 0x0, 0x0, 0x0, 0xff, 0x7f, 0x7f, 0x7f, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff,
7764 0x88, 0x0, 0x15, 0xff, 0xed, 0x1c, 0x24, 0xff, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x0, 0xff,
7765 0xc8, 0xbf, 0xe7, 0xff, 0x70, 0x92, 0xbe, 0xff, 0x99, 0xd9, 0xea, 0xff, 0xb5, 0xe6, 0x1d, 0xff,
7766 0xa3, 0x49, 0xa4, 0xff, 0x3f, 0x48, 0xcc, 0xff, 0x0, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0xff,
7768 0x0, 0x0, 0x0, 0xff, 0x7f, 0x7f, 0x7f, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff,
7769 0x88, 0x0, 0x15, 0xff, 0xed, 0x1c, 0x24, 0xff, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x0, 0xff,
7770 0xc8, 0xbf, 0xe7, 0xff, 0x70, 0x92, 0xbe, 0xff, 0x99, 0xd9, 0xea, 0xff, 0xb5, 0xe6, 0x1d, 0xff,
7771 0xa3, 0x49, 0xa4, 0xff, 0x3f, 0x48, 0xcc, 0xff, 0x0, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0xff
7774 /** Reference data parameters. */
7775 const glw::GLuint GetLevelParameterTest::s_texture_width = 4;
7776 const glw::GLuint GetLevelParameterTest::s_texture_height = 4;
7777 const glw::GLuint GetLevelParameterTest::s_texture_depth = 4;
7779 /** @brief Get Level Parameter Test cases.
7781 * @return Iteration result.
7783 tcu::TestNode::IterateResult GetLevelParameterTest::iterate()
7785 /* Shortcut for GL functionality. */
7786 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7788 /* Get context setup. */
7789 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
7790 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
7792 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
7794 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
7799 /* Running tests. */
7801 bool is_error = false;
7804 glw::GLuint texture = 0;
7808 /* Texture initiation. */
7809 gl.genTextures(1, &texture);
7810 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
7812 gl.bindTexture(GL_TEXTURE_3D, texture);
7813 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
7815 gl.texImage3D(GL_TEXTURE_3D, 0, GL_RGBA8, s_texture_width, s_texture_height, s_texture_depth, 0, GL_RGBA,
7816 GL_UNSIGNED_BYTE, s_texture_data);
7817 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
7819 gl.texImage3D(GL_TEXTURE_3D, 1, GL_RGBA8, s_texture_width / 2, s_texture_height / 2, s_texture_depth / 2, 0,
7820 GL_RGBA, GL_UNSIGNED_BYTE, s_texture_data);
7821 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
7823 static const glw::GLenum pnames[] = {
7824 GL_TEXTURE_WIDTH, GL_TEXTURE_HEIGHT, GL_TEXTURE_DEPTH, GL_TEXTURE_INTERNAL_FORMAT,
7825 GL_TEXTURE_RED_TYPE, GL_TEXTURE_GREEN_TYPE, GL_TEXTURE_BLUE_TYPE, GL_TEXTURE_ALPHA_TYPE,
7826 GL_TEXTURE_DEPTH_TYPE, GL_TEXTURE_RED_SIZE, GL_TEXTURE_GREEN_SIZE, GL_TEXTURE_BLUE_SIZE,
7827 GL_TEXTURE_ALPHA_SIZE, GL_TEXTURE_DEPTH_SIZE, GL_TEXTURE_COMPRESSED
7829 static const glw::GLuint pnames_count = sizeof(pnames) / sizeof(pnames[0]);
7831 /* Test GetTextureLevelParameteriv. */
7832 for (glw::GLuint i = 0; i < 2 /* levels */; ++i)
7834 for (glw::GLuint j = 0; j < pnames_count; ++j)
7836 glw::GLint result_legacy = 0;
7837 glw::GLint result_dsa = 0;
7839 /* Quering reference value. */
7840 gl.getTexLevelParameteriv(GL_TEXTURE_3D, i, pnames[j], &result_legacy);
7841 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
7843 /* Quering using DSA function. */
7844 gl.getTextureLevelParameteriv(texture, i, pnames[j], &result_dsa);
7846 /* Check for errors. */
7847 glw::GLenum error = GL_NO_ERROR;
7849 if (GL_NO_ERROR != (error = gl.getError()))
7851 m_context.getTestContext().getLog()
7852 << tcu::TestLog::Message << "GetTextureLevelParameteriv unexpectedly generated error "
7853 << glu::getErrorStr(error) << ". Test fails." << tcu::TestLog::EndMessage;
7859 /* Compare values. */
7860 if (result_legacy != result_dsa)
7862 m_context.getTestContext().getLog()
7863 << tcu::TestLog::Message << "For parameter name "
7864 << glu::getTextureLevelParameterStr(pnames[j]) << " GetTextureLevelParameteriv returned "
7865 << result_dsa << ", but reference value (queried using GetTexLevelParameteriv) was "
7866 << result_legacy << ". Test fails." << tcu::TestLog::EndMessage;
7874 /* Test GetTextureLevelParameterfv. */
7875 for (glw::GLuint i = 0; i < 2 /* levels */; ++i)
7877 for (glw::GLuint j = 0; j < pnames_count; ++j)
7879 glw::GLfloat result_legacy = 0.f;
7880 glw::GLfloat result_dsa = 0.f;
7882 /* Quering reference value. */
7883 gl.getTexLevelParameterfv(GL_TEXTURE_3D, i, pnames[j], &result_legacy);
7884 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameterfv has failed");
7886 /* Quering using DSA function. */
7887 gl.getTextureLevelParameterfv(texture, i, pnames[j], &result_dsa);
7889 /* Check for errors. */
7890 glw::GLenum error = GL_NO_ERROR;
7892 if (GL_NO_ERROR != (error = gl.getError()))
7894 m_context.getTestContext().getLog()
7895 << tcu::TestLog::Message << "GetTextureLevelParameterfv unexpectedly generated error "
7896 << glu::getErrorStr(error) << ". Test fails." << tcu::TestLog::EndMessage;
7902 /* Compare values. */
7903 if (de::abs(result_legacy - result_dsa) > 0.125 /* Precision. */)
7905 m_context.getTestContext().getLog()
7906 << tcu::TestLog::Message << "For parameter name "
7907 << glu::getTextureLevelParameterStr(pnames[j]) << " GetTextureLevelParameterfv returned "
7908 << result_dsa << ", but reference value (queried using GetTexLevelParameterfv) was "
7909 << result_legacy << ". Test fails." << tcu::TestLog::EndMessage;
7926 gl.deleteTextures(1, &texture);
7929 while (GL_NO_ERROR != gl.getError())
7932 /* Result's setup. */
7935 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
7941 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
7945 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
7952 /*********************************** Errors Utility Class *****************************************************/
7954 /** @brief Check for errors and log.
7956 * @param [in] context Test's context.
7957 * @param [in] expected_error Expected error value.
7958 * @param [in] function_name Name of the function (to be logged).
7959 * @param [in] log Log message.
7961 * @return True if error is equal to expected, false otherwise.
7963 bool ErrorsUtilities::CheckErrorAndLog(deqp::Context& context, glw::GLuint expected_error,
7964 const glw::GLchar* function_name, const glw::GLchar* log)
7966 /* Shortcut for GL functionality. */
7967 const glw::Functions& gl = context.getRenderContext().getFunctions();
7970 glw::GLenum error = GL_NO_ERROR;
7972 if (expected_error != (error = gl.getError()))
7974 context.getTestContext().getLog() << tcu::TestLog::Message << function_name << " generated error "
7975 << glu::getErrorStr(error) << " but, " << glu::getErrorStr(expected_error)
7976 << " was expected if " << log << tcu::TestLog::EndMessage;
7984 /******************************** Creation Errors Test Implementation ********************************/
7986 /** @brief Creation Errors Test constructor.
7988 * @param [in] context OpenGL context.
7990 CreationErrorsTest::CreationErrorsTest(deqp::Context& context)
7991 : deqp::TestCase(context, "textures_creation_errors", "Texture Objects Creation Errors Test")
7993 /* Intentionally left blank. */
7996 /** @brief Iterate Creation Errors Test cases.
7998 * @return Iteration result.
8000 tcu::TestNode::IterateResult CreationErrorsTest::iterate()
8002 /* Shortcut for GL functionality. */
8003 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8005 /* Get context setup. */
8006 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
8007 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
8009 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
8011 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
8016 /* Running tests. */
8018 bool is_error = false;
8020 /* Textures' objects */
8021 glw::GLuint texture = 0;
8025 /* Not a target test. */
8026 gl.createTextures(NotATarget(), 1, &texture);
8027 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glCreateTextures",
8028 "target is not one of the allowable values.");
8032 gl.deleteTextures(1, &texture);
8037 /* Negative number of textures. */
8038 gl.createTextures(GL_TEXTURE_2D, -1, &texture);
8039 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCreateTextures", "n is negative.");
8050 gl.deleteTextures(1, &texture);
8053 /* Errors clean up. */
8054 while (gl.getError())
8057 /* Result's setup. */
8060 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
8066 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
8070 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
8077 /** @brief Function retruns enum which is not a texture target.
8079 glw::GLenum CreationErrorsTest::NotATarget()
8081 static const glw::GLenum texture_targets[] = { GL_TEXTURE_1D,
8084 GL_TEXTURE_1D_ARRAY,
8085 GL_TEXTURE_2D_ARRAY,
8086 GL_TEXTURE_RECTANGLE,
8087 GL_TEXTURE_CUBE_MAP,
8088 GL_TEXTURE_CUBE_MAP_ARRAY,
8090 GL_TEXTURE_2D_MULTISAMPLE,
8091 GL_TEXTURE_2D_MULTISAMPLE_ARRAY };
8093 glw::GLenum not_a_target = 0;
8094 bool is_target = true;
8102 for (glw::GLuint i = 0; i < sizeof(texture_targets) / sizeof(texture_targets[0]); ++i)
8104 if (texture_targets[i] == not_a_target)
8112 return not_a_target;
8115 /******************************** Texture Buffer Errors Test Implementation ********************************/
8117 /** @brief Texture Buffer Errors Test constructor.
8119 * @param [in] context OpenGL context.
8121 BufferErrorsTest::BufferErrorsTest(deqp::Context& context)
8122 : deqp::TestCase(context, "textures_buffer_errors", "Texture Buffer Errors Test")
8124 /* Intentionally left blank. */
8127 /** @brief Iterate Texture Buffer Errors Test cases.
8129 * @return Iteration result.
8131 tcu::TestNode::IterateResult BufferErrorsTest::iterate()
8133 /* Shortcut for GL functionality. */
8134 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8136 /* Get context setup. */
8137 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
8138 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
8140 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
8142 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
8147 /* Running tests. */
8149 bool is_error = false;
8151 /* Textures' objects */
8152 glw::GLuint texture_buffer = 0;
8153 glw::GLuint texture_1D = 0;
8154 glw::GLuint buffer = 0;
8156 static const glw::GLubyte data[4] = { 1, 2, 3, 4 };
8157 static const glw::GLuint data_size = sizeof(data);
8161 /* Auxiliary objects setup. */
8162 gl.createTextures(GL_TEXTURE_BUFFER, 1, &texture_buffer);
8163 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8165 gl.createTextures(GL_TEXTURE_1D, 1, &texture_1D);
8166 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8168 gl.createBuffers(1, &buffer);
8169 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateBuffers has failed");
8171 gl.namedBufferData(buffer, data_size, data, GL_STATIC_COPY);
8172 GLU_EXPECT_NO_ERROR(gl.getError(), "glNamedBufferData has failed");
8174 /* Check that INVALID_OPERATION is generated by glTextureBuffer if texture
8175 is not the name of an existing texture object. */
8177 glw::GLuint not_a_texture = 0;
8179 while (gl.isTexture(++not_a_texture))
8181 GLU_EXPECT_NO_ERROR(gl.getError(), "glIsTexture has failed");
8183 gl.textureBuffer(not_a_texture, GL_RGBA8, buffer);
8185 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureBuffer",
8186 "texture is not the name of an existing texture object.");
8189 /* Check that INVALID_ENUM is generated by glTextureBuffer if the effective
8190 target of texture is not TEXTURE_BUFFER. */
8192 gl.textureBuffer(texture_1D, GL_RGBA8, buffer);
8194 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureBuffer",
8195 "the effective target of texture is not TEXTURE_BUFFER.");
8198 /* Check that INVALID_ENUM is generated if internalformat is not one of the
8199 sized internal formats described above. */
8201 gl.textureBuffer(texture_buffer, GL_COMPRESSED_SIGNED_RED_RGTC1, buffer);
8203 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureBuffer",
8204 "internalformat is not one of the sized internal formats described above..");
8207 /* Check that INVALID_OPERATION is generated if buffer is not zero and is
8208 not the name of an existing buffer object. */
8210 glw::GLuint not_a_buffer = 0;
8212 while (gl.isBuffer(++not_a_buffer))
8214 GLU_EXPECT_NO_ERROR(gl.getError(), "glIsBuffer has failed");
8216 gl.textureBuffer(texture_buffer, GL_RGBA8, not_a_buffer);
8218 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureBuffer",
8219 "buffer is not zero and is not the name of an existing buffer object.");
8231 gl.deleteTextures(1, &texture_1D);
8236 gl.deleteTextures(1, &texture_buffer);
8241 gl.deleteBuffers(1, &buffer);
8244 /* Errors clean up. */
8245 while (gl.getError())
8248 /* Result's setup. */
8251 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
8257 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
8261 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
8268 /******************************** Texture Buffer Range Errors Test Implementation ********************************/
8270 /** @brief Texture Buffer Range Errors Test constructor.
8272 * @param [in] context OpenGL context.
8274 BufferRangeErrorsTest::BufferRangeErrorsTest(deqp::Context& context)
8275 : deqp::TestCase(context, "textures_buffer_range_errors", "Texture Buffer Range Errors Test")
8277 /* Intentionally left blank. */
8280 /** @brief Iterate Texture Buffer Range Errors Test cases.
8282 * @return Iteration result.
8284 tcu::TestNode::IterateResult BufferRangeErrorsTest::iterate()
8286 /* Shortcut for GL functionality. */
8287 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8289 /* Get context setup. */
8290 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
8291 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
8293 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
8295 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
8300 /* Running tests. */
8302 bool is_error = false;
8304 /* Textures' objects */
8305 glw::GLuint texture_buffer = 0;
8306 glw::GLuint texture_1D = 0;
8307 glw::GLuint buffer = 0;
8309 static const glw::GLubyte data[4] = { 1, 2, 3, 4 };
8310 static const glw::GLuint data_size = sizeof(data);
8314 /* Auxiliary objects setup. */
8315 gl.createTextures(GL_TEXTURE_BUFFER, 1, &texture_buffer);
8316 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8318 gl.createTextures(GL_TEXTURE_1D, 1, &texture_1D);
8319 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8321 gl.createBuffers(1, &buffer);
8322 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateBuffers has failed");
8324 gl.namedBufferData(buffer, data_size, data, GL_STATIC_COPY);
8325 GLU_EXPECT_NO_ERROR(gl.getError(), "glNamedBufferData has failed");
8327 /* Check that INVALID_OPERATION is generated by TextureBufferRange if
8328 texture is not the name of an existing texture object.*/
8330 glw::GLuint not_a_texture = 0;
8332 while (gl.isTexture(++not_a_texture))
8334 GLU_EXPECT_NO_ERROR(gl.getError(), "glIsTexture has failed");
8336 gl.textureBufferRange(not_a_texture, GL_RGBA8, buffer, 0, data_size);
8338 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureBufferRange",
8339 "texture is not the name of an existing texture object.");
8342 /* Check that INVALID_ENUM is generated by TextureBufferRange if the
8343 effective target of texture is not TEXTURE_BUFFER. */
8345 gl.textureBufferRange(texture_1D, GL_RGBA8, buffer, 0, data_size);
8347 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureBufferRange",
8348 "the effective target of texture is not TEXTURE_BUFFER.");
8351 /* Check that INVALID_ENUM is generated by TextureBufferRange if
8352 internalformat is not one of the sized internal formats described above. */
8354 gl.textureBufferRange(texture_buffer, GL_COMPRESSED_SIGNED_RED_RGTC1, buffer, 0, data_size);
8356 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureBufferRange",
8357 "internalformat is not one of the supported sized internal formats.");
8360 /* Check that INVALID_OPERATION is generated by TextureBufferRange if
8361 buffer is not zero and is not the name of an existing buffer object. */
8363 glw::GLuint not_a_buffer = 0;
8365 while (gl.isBuffer(++not_a_buffer))
8367 GLU_EXPECT_NO_ERROR(gl.getError(), "glIsBuffer has failed");
8369 gl.textureBufferRange(texture_buffer, GL_RGBA8, not_a_buffer, 0, data_size);
8371 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureBufferRange",
8372 "buffer is not zero and is not the name of an existing buffer object.");
8375 /* Check that INVALID_VALUE is generated by TextureBufferRange if offset
8376 is negative, if size is less than or equal to zero, or if offset + size
8377 is greater than the value of BUFFER_SIZE for buffer. */
8379 gl.textureBufferRange(texture_buffer, GL_RGBA8, buffer, -1, data_size);
8381 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureBufferRange", "offset is negative.");
8383 gl.textureBufferRange(texture_buffer, GL_RGBA8, buffer, 0, 0);
8385 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureBufferRange", "size is zero.");
8387 gl.textureBufferRange(texture_buffer, GL_RGBA8, buffer, 0, -1);
8389 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureBufferRange", "size is negative.");
8391 gl.textureBufferRange(texture_buffer, GL_RGBA8, buffer, 0, data_size * 16);
8393 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureBufferRange",
8394 "size is greater than the value of BUFFER_SIZE for buffer.");
8397 /* Check that INVALID_VALUE is generated by TextureBufferRange if offset is
8398 not an integer multiple of the value of TEXTURE_BUFFER_OFFSET_ALIGNMENT. */
8400 glw::GLint gl_texture_buffer_offset_alignment = 0;
8402 gl.getIntegerv(GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT, &gl_texture_buffer_offset_alignment);
8404 /* If alignmet is 1 we cannot do anything. Error situtation is impossible then. */
8405 if (gl_texture_buffer_offset_alignment > 1)
8407 gl.textureBufferRange(texture_buffer, GL_RGBA8, buffer, 1, data_size - 1);
8409 is_ok &= CheckErrorAndLog(
8410 m_context, GL_INVALID_VALUE, "glTextureBufferRange",
8411 "offset is not an integer multiple of the value of TEXTURE_BUFFER_OFFSET_ALIGNMENT.");
8424 gl.deleteTextures(1, &texture_1D);
8429 gl.deleteTextures(1, &texture_buffer);
8434 gl.deleteBuffers(1, &buffer);
8437 /* Errors clean up. */
8438 while (gl.getError())
8441 /* Result's setup. */
8444 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
8450 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
8454 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
8461 /******************************** Texture Storage Errors Test Implementation ********************************/
8463 /** @brief Texture Storage Errors Test constructor.
8465 * @param [in] context OpenGL context.
8467 StorageErrorsTest::StorageErrorsTest(deqp::Context& context)
8468 : deqp::TestCase(context, "textures_storage_errors", "Texture Storage Errors Test")
8475 , m_to_2D_ms_immutable(0)
8477 , m_to_3D_ms_immutable(0)
8479 , m_internalformat_invalid(0)
8480 , m_max_texture_size(1)
8482 , m_max_array_texture_layers(1)
8484 /* Intentionally left blank. */
8487 /** @brief Iterate Texture Storage Errors Test cases.
8489 * @return Iteration result.
8491 tcu::TestNode::IterateResult StorageErrorsTest::iterate()
8493 /* Get context setup. */
8494 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
8495 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
8497 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
8499 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
8504 /* Running tests. */
8506 bool is_error = false;
8515 is_ok &= Test2DMultisample();
8516 is_ok &= Test3DMultisample();
8527 /* Result's setup. */
8530 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
8536 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
8540 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
8547 /** @brief Prepare test objects.
8549 void StorageErrorsTest::Prepare()
8551 /* Shortcut for GL functionality. */
8552 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8554 /* Auxiliary objects setup. */
8557 gl.createTextures(GL_TEXTURE_1D, 1, &m_to_1D);
8558 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8561 gl.createTextures(GL_TEXTURE_1D_ARRAY, 1, &m_to_1D_array);
8562 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8565 gl.createTextures(GL_TEXTURE_2D, 1, &m_to_2D);
8566 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8569 gl.createTextures(GL_TEXTURE_2D_ARRAY, 1, &m_to_2D_array);
8570 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8573 gl.createTextures(GL_TEXTURE_3D, 1, &m_to_3D);
8574 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8576 /* 2D Multisample */
8577 gl.createTextures(GL_TEXTURE_2D_MULTISAMPLE, 1, &m_to_2D_ms);
8578 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8580 /* 2D Multisample with storage */
8581 gl.createTextures(GL_TEXTURE_2D_MULTISAMPLE, 1, &m_to_2D_ms_immutable);
8582 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8584 gl.textureStorage2DMultisample(m_to_2D_ms_immutable, 1, GL_R8, 16, 16, false);
8585 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage2DMultisample has failed");
8587 /* 3D Multisample */
8588 gl.createTextures(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, 1, &m_to_3D_ms);
8589 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8591 /* 3D Multisample with storage */
8592 gl.createTextures(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, 1, &m_to_3D_ms_immutable);
8593 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8595 gl.textureStorage3DMultisample(m_to_3D_ms_immutable, 1, GL_R8, 16, 16, 16, false);
8596 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage2DMultisample has failed");
8598 /* Invalid values */
8600 /* invalid texture object */
8601 while (gl.isTexture(++m_to_invalid))
8603 GLU_EXPECT_NO_ERROR(gl.getError(), "glIsTexture has failed");
8605 /* invalid internal format */
8606 static const glw::GLenum all_internal_formats[] = { GL_R8,
8675 GL_COMPRESSED_SRGB_ALPHA,
8676 GL_COMPRESSED_RED_RGTC1,
8677 GL_COMPRESSED_SIGNED_RED_RGTC1,
8678 GL_COMPRESSED_RG_RGTC2,
8679 GL_COMPRESSED_SIGNED_RG_RGTC2,
8680 GL_COMPRESSED_RGBA_BPTC_UNORM,
8681 GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM,
8682 GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT,
8683 GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT,
8684 GL_COMPRESSED_RGB8_ETC2,
8685 GL_COMPRESSED_SRGB8_ETC2,
8686 GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
8687 GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
8688 GL_COMPRESSED_RGBA8_ETC2_EAC,
8689 GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
8690 GL_COMPRESSED_R11_EAC,
8691 GL_COMPRESSED_SIGNED_R11_EAC,
8692 GL_COMPRESSED_RG11_EAC,
8693 GL_COMPRESSED_SIGNED_RG11_EAC,
8694 GL_DEPTH_COMPONENT16,
8695 GL_DEPTH_COMPONENT24,
8696 GL_DEPTH_COMPONENT32,
8697 GL_DEPTH_COMPONENT32F,
8698 GL_DEPTH24_STENCIL8,
8699 GL_DEPTH32F_STENCIL8,
8703 GL_STENCIL_INDEX16 };
8705 static const glw::GLuint all_internal_formats_count =
8706 sizeof(all_internal_formats) / sizeof(all_internal_formats[0]);
8708 bool is_valid = true;
8709 m_internalformat_invalid = 0;
8714 m_internalformat_invalid++;
8715 for (glw::GLuint i = 0; i < all_internal_formats_count; ++i)
8717 if (all_internal_formats[i] == m_internalformat_invalid)
8725 /* Maximum texture size.*/
8726 gl.getIntegerv(GL_MAX_TEXTURE_SIZE, &m_max_texture_size);
8727 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
8729 /* Maximum number of samples. */
8730 gl.getIntegerv(GL_MAX_SAMPLES, &m_max_samples);
8731 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
8733 /* Maximum number of array texture layers. */
8734 gl.getIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &m_max_array_texture_layers);
8735 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
8738 /** @brief Test TextureStorage1D
8740 * @return Test result.
8742 bool StorageErrorsTest::Test1D()
8744 /* Shortcut for GL functionality. */
8745 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8750 /* Check that INVALID_OPERATION is generated by TextureStorage1D if texture
8751 is not the name of an existing texture object. */
8753 gl.textureStorage1D(m_to_invalid, 1, GL_R8, 8);
8754 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage1D",
8755 "texture is not the name of an existing texture object.");
8758 /* Check that INVALID_ENUM is generated by TextureStorage1D if
8759 internalformat is not a valid sized internal format. */
8761 gl.textureStorage1D(m_to_1D, 1, m_internalformat_invalid, 8);
8762 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureStorage1D",
8763 "internalformat is not a valid sized internal format.");
8766 /* Check that INVALID_ENUM is generated by TextureStorage1D if target or
8767 the effective target of texture is not one of the accepted targets
8770 gl.textureStorage1D(m_to_2D, 1, GL_R8, 8);
8771 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage1D",
8772 "the effective target of texture is not one of the accepted targets.");
8775 /* Check that INVALID_VALUE is generated by TextureStorage1D if width or
8776 levels are less than 1. */
8778 gl.textureStorage1D(m_to_1D, 0, GL_R8, 8);
8779 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage1D", "levels is less than 1.");
8781 gl.textureStorage1D(m_to_1D, 1, GL_R8, 0);
8782 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage1D", "width is less than 1.");
8785 /* Check that INVALID_OPERATION is generated by TextureStorage1D if levels
8786 is greater than log2(width)+1. */
8788 gl.textureStorage1D(m_to_1D, 8, GL_R8, 8);
8789 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage1D",
8790 "levels is greater than log2(width)+1.");
8796 /** @brief Test TextureStorage2D
8798 * @return Test result.
8800 bool StorageErrorsTest::Test2D()
8802 /* Shortcut for GL functionality. */
8803 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8808 /* Check that INVALID_OPERATION is generated by TextureStorage2D if
8809 texture is not the name of an existing texture object. */
8811 gl.textureStorage2D(m_to_invalid, 1, GL_R8, 8, 8);
8812 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage2D",
8813 "texture is not the name of an existing texture object.");
8816 /* Check that INVALID_ENUM is generated by TextureStorage2D if
8817 internalformat is not a valid sized internal format. */
8819 gl.textureStorage2D(m_to_2D, 1, m_internalformat_invalid, 8, 8);
8820 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureStorage2D",
8821 "internalformat is not a valid sized internal format.");
8824 /* Check that INVALID_ENUM is generated by TextureStorage2D if target or
8825 the effective target of texture is not one of the accepted targets
8828 gl.textureStorage2D(m_to_1D, 1, GL_R8, 8, 8);
8829 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage2D",
8830 "the effective target of texture is not one of the accepted targets.");
8833 /* Check that INVALID_VALUE is generated by TextureStorage2D if width,
8834 height or levels are less than 1. */
8836 gl.textureStorage2D(m_to_2D, 0, GL_R8, 8, 8);
8837 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage2D", "levels is less than 1.");
8839 gl.textureStorage2D(m_to_2D, 1, GL_R8, 0, 8);
8840 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage2D", "width is less than 1.");
8842 gl.textureStorage2D(m_to_2D, 1, GL_R8, 8, 0);
8843 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage2D", "height is less than 1.");
8846 /* Check that INVALID_OPERATION is generated by TextureStorage2D if target
8847 is TEXTURE_1D_ARRAY or PROXY_TEXTURE_1D_ARRAY and levels is greater than
8850 gl.textureStorage2D(m_to_1D_array, 8, GL_R8, 8, 8);
8851 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage2D",
8852 "target is TEXTURE_1D_ARRAY and levels is greater than log2(width)+1.");
8855 /* Check that INVALID_OPERATION is generated by TextureStorage2D if target
8856 is not TEXTURE_1D_ARRAY or PROXY_TEXTURE_1D_ARRAY and levels is greater
8857 than log2(max(width, height))+1. */
8859 gl.textureStorage2D(m_to_2D, 8, GL_R8, 8, 8);
8860 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage2D",
8861 "target is TEXTURE_2D and levels is greater than log2(max(width, height))+1.");
8867 /** @brief Test TextureStorage3D
8869 * @return Test result.
8871 bool StorageErrorsTest::Test3D()
8873 /* Shortcut for GL functionality. */
8874 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8879 /* Check that INVALID_OPERATION is generated by TextureStorage3D if texture
8880 is not the name of an existing texture object. */
8882 gl.textureStorage3D(m_to_invalid, 1, GL_R8, 8, 8, 8);
8883 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage3D",
8884 "texture is not the name of an existing texture object.");
8887 /* Check that INVALID_ENUM is generated by TextureStorage3D if
8888 internalformat is not a valid sized internal format. */
8890 gl.textureStorage3D(m_to_3D, 1, m_internalformat_invalid, 8, 8, 8);
8891 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureStorage3D",
8892 "internalformat is not a valid sized internal format.");
8895 /* Check that INVALID_ENUM is generated by TextureStorage3D if target or
8896 the effective target of texture is not one of the accepted targets
8899 gl.textureStorage3D(m_to_1D, 1, GL_R8, 8, 8, 8);
8900 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage3D",
8901 "the effective target of texture is not one of the accepted targets.");
8904 /* Check that INVALID_VALUE is generated by TextureStorage3D if width,
8905 height, depth or levels are less than 1. */
8907 gl.textureStorage3D(m_to_3D, 0, GL_R8, 8, 8, 8);
8908 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage3D", "levels is less than 1.");
8910 gl.textureStorage3D(m_to_3D, 1, GL_R8, 0, 8, 8);
8911 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage3D", "width is less than 1.");
8913 gl.textureStorage3D(m_to_3D, 1, GL_R8, 8, 0, 8);
8914 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage3D", "height is less than 1.");
8916 gl.textureStorage3D(m_to_3D, 1, GL_R8, 8, 8, 0);
8917 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage3D", "depth is less than 1.");
8920 /* Check that INVALID_OPERATION is generated by TextureStorage3D if target
8921 is TEXTURE_3D or PROXY_TEXTURE_3D and levels is greater than
8922 log2(max(width, height, depth))+1. */
8924 gl.textureStorage3D(m_to_3D, 8, GL_R8, 8, 8, 8);
8925 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage3D",
8926 "target is TEXTURE_3D and levels is greater than log2(max(width, height, depth))+1.");
8929 /* Check that INVALID_OPERATION is generated by TextureStorage3D if target
8930 is TEXTURE_2D_ARRAY, PROXY_TEXTURE_2D_ARRAY, TEXURE_CUBE_ARRAY,
8931 or PROXY_TEXTURE_CUBE_MAP_ARRAY and levels is greater than
8932 log2(max(width, height))+1. */
8934 gl.textureStorage3D(m_to_2D_array, 6, GL_R8, 8, 8, 256);
8935 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage3D",
8936 "target is TEXTURE_2D_ARRAY and levels is greater than log2(max(width, height))+1.");
8942 /** @brief Test TextureStorage2DMultisample
8944 * @return Test result.
8946 bool StorageErrorsTest::Test2DMultisample()
8948 /* Shortcut for GL functionality. */
8949 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8954 /* Check that INVALID_OPERATION is generated by TextureStorage2DMultisample
8955 if texture is not the name of an existing texture object. */
8957 gl.textureStorage2DMultisample(m_to_invalid, 1, GL_R8, 8, 8, false);
8958 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage2DMultisample",
8959 "texture is not the name of an existing texture object.");
8962 /* Check that INVALID_ENUM is generated by TextureStorage2DMultisample if
8963 internalformat is not a valid color-renderable, depth-renderable or
8964 stencil-renderable format. */
8966 gl.textureStorage2DMultisample(m_to_2D_ms, 1, m_internalformat_invalid, 8, 8, false);
8967 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureStorage2DMultisample",
8968 "internalformat is not a valid sized internal format.");
8971 /* Check that INVALID_OPERATION is generated by TextureStorage2DMultisample if
8972 target or the effective target of texture is not one of the accepted
8973 targets described above. */
8975 gl.textureStorage2DMultisample(m_to_1D, 1, GL_R8, 8, 8, false);
8976 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage2DMultisample",
8977 "the effective target of texture is not one of the accepted targets.");
8980 /* Check that INVALID_VALUE is generated by TextureStorage2DMultisample if
8981 width or height are less than 1 or greater than the value of
8982 MAX_TEXTURE_SIZE. */
8984 gl.textureStorage2DMultisample(m_to_2D_ms, 1, GL_R8, 0, 8, false);
8986 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage2DMultisample", "width is less than 1.");
8988 gl.textureStorage2DMultisample(m_to_2D_ms, 1, GL_R8, 8, 0, false);
8990 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage2DMultisample", "height is less than 1.");
8992 gl.textureStorage2DMultisample(m_to_2D_ms, 1, GL_R8, m_max_texture_size * 2, 8, false);
8993 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage2DMultisample",
8994 "width is greater than the value of MAX_TEXTURE_SIZE.");
8996 gl.textureStorage2DMultisample(m_to_2D_ms, 1, GL_R8, 8, m_max_texture_size * 2, false);
8997 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage2DMultisample",
8998 "height is greater than the value of MAX_TEXTURE_SIZE.");
9001 /* Check that INVALID_OPERATION is generated by TextureStorage2DMultisample if
9002 samples is greater than the value of MAX_SAMPLES. */
9004 gl.textureStorage2DMultisample(m_to_2D_ms, m_max_samples * 2, GL_R8, 8, 8, false);
9005 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage2DMultisample",
9006 "samples is greater than the value of MAX_SAMPLES.");
9009 /* Check that INVALID_OPERATION is generated by TextureStorage2DMultisample
9010 if the value of TEXTURE_IMMUTABLE_FORMAT for the texture bound to target
9013 gl.textureStorage2DMultisample(m_to_2D_ms_immutable, 1, GL_R8, 8, 8, false);
9014 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage2DMultisample",
9015 "samples is greater than the value of MAX_SAMPLES.");
9021 /** @brief Test TextureStorage3DMultisample
9023 * @return Test result.
9025 bool StorageErrorsTest::Test3DMultisample()
9027 /* Shortcut for GL functionality. */
9028 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
9033 /* Check that INVALID_OPERATION is generated by TextureStorage3DMultisample
9034 if texture is not the name of an existing texture object. */
9036 gl.textureStorage3DMultisample(m_to_invalid, 1, GL_R8, 8, 8, 8, false);
9037 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage3DMultisample",
9038 "texture is not the name of an existing texture object.");
9041 /* Check that INVALID_ENUM is generated by TextureStorage3DMultisample if
9042 internalformat is not a valid color-renderable, depth-renderable or
9043 stencil-renderable format. */
9045 gl.textureStorage3DMultisample(m_to_3D_ms, 1, m_internalformat_invalid, 8, 8, 8, false);
9046 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureStorage3DMultisample",
9047 "internalformat is not a valid sized internal format.");
9050 /* Check that INVALID_OPERATION is generated by TextureStorage3DMultisample if
9051 target or the effective target of texture is not one of the accepted
9052 targets described above. */
9054 gl.textureStorage3DMultisample(m_to_1D, 1, GL_R8, 8, 8, 8, false);
9055 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage3DMultisample",
9056 "the effective target of texture is not one of the accepted targets.");
9059 /* Check that INVALID_VALUE is generated by TextureStorage3DMultisample if
9060 width or height are less than 1 or greater than the value of
9061 MAX_TEXTURE_SIZE. */
9063 gl.textureStorage3DMultisample(m_to_3D_ms, 1, GL_R8, 0, 8, 8, false);
9065 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage3DMultisample", "width is less than 1.");
9067 gl.textureStorage3DMultisample(m_to_3D_ms, 1, GL_R8, 8, 0, 8, false);
9069 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage3DMultisample", "height is less than 1.");
9071 gl.textureStorage3DMultisample(m_to_3D_ms, 1, GL_R8, m_max_texture_size * 2, 8, 8, false);
9072 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage3DMultisample",
9073 "width is greater than the value of MAX_TEXTURE_SIZE.");
9075 gl.textureStorage3DMultisample(m_to_3D_ms, 1, GL_R8, 8, m_max_texture_size * 2, 8, false);
9076 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage3DMultisample",
9077 "height is greater than the value of MAX_TEXTURE_SIZE.");
9080 /* Check that INVALID_VALUE is generated by TextureStorage3DMultisample if
9081 depth is less than 1 or greater than the value of
9082 MAX_ARRAY_TEXTURE_LAYERS. */
9084 gl.textureStorage3DMultisample(m_to_3D_ms, 1, GL_R8, 8, 8, 0, false);
9086 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage3DMultisample", "depth is less than 1.");
9088 gl.textureStorage3DMultisample(m_to_3D_ms, 1, GL_R8, 8, 8, m_max_array_texture_layers * 2, false);
9089 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage3DMultisample",
9090 "depth is greater than the value of MAX_ARRAY_TEXTURE_LAYERS.");
9093 /* Check that INVALID_VALUE is generated by TextureStorage3DMultisample if
9094 samples is greater than the value of MAX_SAMPLES. */
9096 gl.textureStorage3DMultisample(m_to_3D_ms, m_max_samples * 2, GL_R8, 8, 8, 8, false);
9097 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage3DMultisample",
9098 "samples is greater than the value of MAX_SAMPLES.");
9101 /* Check that INVALID_OPERATION is generated by TextureStorage3DMultisample
9102 if the value of TEXTURE_IMMUTABLE_FORMAT for the texture bound to target
9105 gl.textureStorage3DMultisample(m_to_3D_ms_immutable, 1, GL_R8, 8, 8, 8, false);
9106 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage3DMultisample",
9107 "samples is greater than the value of MAX_SAMPLES.");
9113 /** @brief Clean GL objects, test variables and GL errors.
9115 void StorageErrorsTest::Clean()
9117 /* Shortcut for GL functionality. */
9118 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
9123 gl.deleteTextures(1, &m_to_1D);
9130 gl.deleteTextures(1, &m_to_1D_array);
9137 gl.deleteTextures(1, &m_to_2D);
9144 gl.deleteTextures(1, &m_to_2D_array);
9151 gl.deleteTextures(1, &m_to_3D);
9158 gl.deleteTextures(1, &m_to_2D_ms);
9163 if (m_to_2D_ms_immutable)
9165 gl.deleteTextures(1, &m_to_2D_ms_immutable);
9167 m_to_2D_ms_immutable = 0;
9172 gl.deleteTextures(1, &m_to_3D_ms);
9177 if (m_to_3D_ms_immutable)
9179 gl.deleteTextures(1, &m_to_3D_ms_immutable);
9181 m_to_3D_ms_immutable = 0;
9185 m_internalformat_invalid = 0;
9186 m_max_texture_size = 1;
9188 m_max_array_texture_layers = 1;
9190 while (GL_NO_ERROR != gl.getError())
9194 /******************************** Texture SubImage Errors Test Implementation ********************************/
9196 /** @brief Texture SubImage Errors Test constructor.
9198 * @param [in] context OpenGL context.
9200 SubImageErrorsTest::SubImageErrorsTest(deqp::Context& context)
9201 : deqp::TestCase(context, "textures_subimage_errors", "Texture SubImage Errors Test")
9208 , m_to_1D_compressed(0)
9209 , m_to_2D_compressed(0)
9210 , m_to_3D_compressed(0)
9211 , m_to_rectangle_compressed(0)
9214 , m_format_invalid(0)
9216 , m_max_texture_size(1)
9217 , m_reference_compressed_1D(DE_NULL)
9218 , m_reference_compressed_2D(DE_NULL)
9219 , m_reference_compressed_3D(DE_NULL)
9220 , m_reference_compressed_rectangle(DE_NULL)
9221 , m_reference_compressed_1D_size(0)
9222 , m_reference_compressed_2D_size(0)
9223 , m_reference_compressed_3D_size(0)
9224 , m_reference_compressed_rectangle_size(0)
9225 , m_reference_compressed_1D_format(0)
9226 , m_reference_compressed_2D_format(0)
9227 , m_reference_compressed_3D_format(0)
9228 , m_reference_compressed_rectangle_format(0)
9229 , m_not_matching_compressed_1D_format(0)
9230 , m_not_matching_compressed_1D_size(0)
9231 , m_not_matching_compressed_2D_format(0)
9232 , m_not_matching_compressed_2D_size(0)
9233 , m_not_matching_compressed_3D_format(0)
9234 , m_not_matching_compressed_3D_size(0)
9236 /* Intentionally left blank. */
9239 /** @brief Iterate Texture SubImage Errors Test cases.
9241 * @return Iteration result.
9243 tcu::TestNode::IterateResult SubImageErrorsTest::iterate()
9245 /* Get context setup. */
9246 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
9247 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
9249 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
9251 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
9256 /* Running tests. */
9258 bool is_error = false;
9267 is_ok &= Test1DCompressed();
9268 is_ok &= Test2DCompressed();
9269 is_ok &= Test3DCompressed();
9280 /* Result's setup. */
9283 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
9289 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
9293 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
9300 /** @brief Prepare test's objects.
9302 void SubImageErrorsTest::Prepare()
9304 /* Shortcut for GL functionality. */
9305 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
9307 /* Auxiliary objects setup. */
9310 gl.createTextures(GL_TEXTURE_1D, 1, &m_to_1D_empty);
9311 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9314 gl.createTextures(GL_TEXTURE_2D, 1, &m_to_2D_empty);
9315 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9318 gl.createTextures(GL_TEXTURE_3D, 1, &m_to_3D_empty);
9319 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9322 gl.createTextures(GL_TEXTURE_1D, 1, &m_to_1D);
9323 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9325 gl.bindTexture(GL_TEXTURE_1D, m_to_1D);
9326 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
9328 gl.texImage1D(GL_TEXTURE_1D, 0, s_reference_internalformat, s_reference_width, 0, s_reference_format,
9329 GL_UNSIGNED_BYTE, s_reference);
9330 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
9333 gl.createTextures(GL_TEXTURE_2D, 1, &m_to_2D);
9334 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9336 gl.bindTexture(GL_TEXTURE_2D, m_to_2D);
9337 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
9339 gl.texImage2D(GL_TEXTURE_2D, 0, s_reference_internalformat, s_reference_width, s_reference_height, 0,
9340 s_reference_format, GL_UNSIGNED_BYTE, s_reference);
9341 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
9344 gl.createTextures(GL_TEXTURE_3D, 1, &m_to_3D);
9345 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9347 gl.bindTexture(GL_TEXTURE_3D, m_to_3D);
9348 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
9350 gl.texImage3D(GL_TEXTURE_3D, 0, s_reference_internalformat, s_reference_width, s_reference_height,
9351 s_reference_depth, 0, s_reference_format, GL_UNSIGNED_BYTE, s_reference);
9352 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
9355 gl.createTextures(GL_TEXTURE_1D, 1, &m_to_1D_compressed);
9356 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9358 gl.bindTexture(GL_TEXTURE_1D, m_to_1D_compressed);
9359 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
9361 gl.texImage1D(GL_TEXTURE_1D, 0, s_reference_internalformat_compressed, s_reference_width, 0, s_reference_format,
9362 GL_UNSIGNED_BYTE, s_reference);
9363 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
9365 glw::GLint is_compressed = 0;
9367 gl.getTexLevelParameteriv(GL_TEXTURE_1D, 0, GL_TEXTURE_COMPRESSED, &is_compressed);
9368 GLU_EXPECT_NO_ERROR(gl.getError(), "glTetTexLevelParameteriv has failed");
9372 gl.getTexLevelParameteriv(GL_TEXTURE_1D, 0, GL_TEXTURE_INTERNAL_FORMAT, &m_reference_compressed_1D_format);
9373 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9375 m_reference_compressed_1D_size = 0;
9377 gl.getTexLevelParameteriv(GL_TEXTURE_1D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &m_reference_compressed_1D_size);
9378 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9380 if (m_reference_compressed_1D_size)
9382 m_reference_compressed_1D = new glw::GLubyte[m_reference_compressed_1D_size];
9384 gl.getCompressedTexImage(GL_TEXTURE_1D, 0, m_reference_compressed_1D);
9385 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
9390 gl.createTextures(GL_TEXTURE_2D, 1, &m_to_2D_compressed);
9391 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9393 gl.bindTexture(GL_TEXTURE_2D, m_to_2D_compressed);
9394 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
9396 gl.texImage2D(GL_TEXTURE_2D, 0, s_reference_internalformat_compressed, s_reference_width, s_reference_height, 0,
9397 s_reference_format, GL_UNSIGNED_BYTE, s_reference);
9398 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
9402 gl.getTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED, &is_compressed);
9403 GLU_EXPECT_NO_ERROR(gl.getError(), "glTetTexLevelParameteriv has failed");
9407 gl.getTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &m_reference_compressed_2D_format);
9408 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9410 m_reference_compressed_2D_size = 0;
9412 gl.getTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &m_reference_compressed_2D_size);
9413 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9415 if (m_reference_compressed_2D_size)
9417 m_reference_compressed_2D = new glw::GLubyte[m_reference_compressed_2D_size];
9419 gl.getCompressedTexImage(GL_TEXTURE_2D, 0, m_reference_compressed_2D);
9420 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
9425 gl.createTextures(GL_TEXTURE_2D_ARRAY, 1, &m_to_3D_compressed);
9426 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9428 gl.bindTexture(GL_TEXTURE_2D_ARRAY, m_to_3D_compressed);
9429 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
9431 gl.texImage3D(GL_TEXTURE_2D_ARRAY, 0, s_reference_internalformat_compressed, s_reference_width, s_reference_height,
9432 s_reference_depth, 0, s_reference_format, GL_UNSIGNED_BYTE, s_reference);
9433 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage3D has failed");
9437 gl.getTexLevelParameteriv(GL_TEXTURE_2D_ARRAY, 0, GL_TEXTURE_COMPRESSED, &is_compressed);
9438 GLU_EXPECT_NO_ERROR(gl.getError(), "glTetTexLevelParameteriv has failed");
9442 gl.getTexLevelParameteriv(GL_TEXTURE_2D_ARRAY, 0, GL_TEXTURE_INTERNAL_FORMAT,
9443 &m_reference_compressed_3D_format);
9444 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9446 m_reference_compressed_3D_size = 0;
9448 gl.getTexLevelParameteriv(GL_TEXTURE_2D_ARRAY, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE,
9449 &m_reference_compressed_3D_size);
9450 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9452 if (m_reference_compressed_3D_size)
9454 m_reference_compressed_3D = new glw::GLubyte[m_reference_compressed_3D_size];
9456 gl.getCompressedTexImage(GL_TEXTURE_2D_ARRAY, 0, m_reference_compressed_3D);
9457 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
9461 /* RECTANGLE Compressed */
9462 gl.createTextures(GL_TEXTURE_RECTANGLE, 1, &m_to_rectangle_compressed);
9463 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9465 gl.bindTexture(GL_TEXTURE_RECTANGLE, m_to_rectangle_compressed);
9466 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
9468 gl.texImage2D(GL_TEXTURE_RECTANGLE, 0, s_reference_internalformat_compressed, s_reference_width, s_reference_height,
9469 0, s_reference_format, GL_UNSIGNED_BYTE, s_reference);
9470 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
9474 gl.getTexLevelParameteriv(GL_TEXTURE_RECTANGLE, 0, GL_TEXTURE_COMPRESSED, &is_compressed);
9475 GLU_EXPECT_NO_ERROR(gl.getError(), "glTetTexLevelParameteriv has failed");
9479 gl.getTexLevelParameteriv(GL_TEXTURE_RECTANGLE, 0, GL_TEXTURE_INTERNAL_FORMAT,
9480 &m_reference_compressed_rectangle_format);
9481 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9483 m_reference_compressed_rectangle_size = 0;
9485 gl.getTexLevelParameteriv(GL_TEXTURE_RECTANGLE, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE,
9486 &m_reference_compressed_rectangle_size);
9487 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9489 if (m_reference_compressed_rectangle_size)
9491 m_reference_compressed_rectangle = new glw::GLubyte[m_reference_compressed_rectangle_size];
9493 gl.getCompressedTexImage(GL_TEXTURE_RECTANGLE, 0, m_reference_compressed_rectangle);
9494 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
9499 gl.createBuffers(1, &m_bo);
9500 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateBuffers has failed");
9502 gl.namedBufferData(m_bo, s_reference_size, s_reference, GL_STATIC_COPY);
9503 GLU_EXPECT_NO_ERROR(gl.getError(), "glNamedBufferData has failed");
9505 /* Invalid values */
9507 /* invalid texture object */
9508 while (gl.isTexture(++m_to_invalid))
9510 GLU_EXPECT_NO_ERROR(gl.getError(), "glIsTexture has failed");
9512 /* invalid internal format */
9513 static const glw::GLenum all_formats[] = { GL_STENCIL_INDEX,
9533 static const glw::GLuint all_internal_formats_count = sizeof(all_formats) / sizeof(all_formats[0]);
9535 bool is_valid = true;
9536 m_format_invalid = 0;
9542 for (glw::GLuint i = 0; i < all_internal_formats_count; ++i)
9544 if (all_formats[i] == m_format_invalid)
9553 static const glw::GLenum all_types[] = { GL_UNSIGNED_BYTE,
9561 GL_UNSIGNED_BYTE_3_3_2,
9562 GL_UNSIGNED_BYTE_2_3_3_REV,
9563 GL_UNSIGNED_SHORT_5_6_5,
9564 GL_UNSIGNED_SHORT_5_6_5_REV,
9565 GL_UNSIGNED_SHORT_4_4_4_4,
9566 GL_UNSIGNED_SHORT_4_4_4_4_REV,
9567 GL_UNSIGNED_SHORT_5_5_5_1,
9568 GL_UNSIGNED_SHORT_1_5_5_5_REV,
9569 GL_UNSIGNED_INT_8_8_8_8,
9570 GL_UNSIGNED_INT_8_8_8_8_REV,
9571 GL_UNSIGNED_INT_10_10_10_2,
9572 GL_UNSIGNED_INT_2_10_10_10_REV,
9573 GL_UNSIGNED_INT_24_8,
9574 GL_UNSIGNED_INT_10F_11F_11F_REV,
9575 GL_UNSIGNED_INT_5_9_9_9_REV,
9576 GL_FLOAT_32_UNSIGNED_INT_24_8_REV };
9578 static const glw::GLuint all_types_count = sizeof(all_types) / sizeof(all_types[0]);
9587 for (glw::GLuint i = 0; i < all_types_count; ++i)
9589 if (all_types[i] == m_type_invalid)
9597 /* Maximum texture size.*/
9598 gl.getIntegerv(GL_MAX_TEXTURE_SIZE, &m_max_texture_size);
9599 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
9601 glw::GLenum not_matching_format = GL_RED;
9602 glw::GLenum not_matching_internalformat_compressed = GL_COMPRESSED_RED;
9604 /* 1D Compressed with a non matching format. We need to do all the allocation to get the correct image size */
9605 glw::GLuint to_1D_compressed_not_matching;
9607 gl.createTextures(GL_TEXTURE_1D, 1, &to_1D_compressed_not_matching);
9608 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9610 gl.bindTexture(GL_TEXTURE_1D, to_1D_compressed_not_matching);
9611 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
9613 gl.texImage1D(GL_TEXTURE_1D, 0, not_matching_internalformat_compressed, s_reference_width, 0, s_reference_format,
9614 GL_UNSIGNED_BYTE, s_reference);
9615 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
9619 gl.getTexLevelParameteriv(GL_TEXTURE_1D, 0, GL_TEXTURE_COMPRESSED, &is_compressed);
9620 GLU_EXPECT_NO_ERROR(gl.getError(), "glTetTexLevelParameteriv has failed");
9624 gl.getTexLevelParameteriv(GL_TEXTURE_1D, 0, GL_TEXTURE_INTERNAL_FORMAT, &m_not_matching_compressed_1D_format);
9625 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9627 m_not_matching_compressed_1D_size = 0;
9629 gl.getTexLevelParameteriv(GL_TEXTURE_1D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE,
9630 &m_not_matching_compressed_1D_size);
9631 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9634 gl.deleteTextures(1, &to_1D_compressed_not_matching);
9635 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9637 /* 2D Compressed with a non matching format. We need to do all the allocation to get the correct image size */
9638 glw::GLuint to_2D_compressed_not_matching;
9640 gl.createTextures(GL_TEXTURE_2D, 1, &to_2D_compressed_not_matching);
9641 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9643 gl.bindTexture(GL_TEXTURE_2D, to_2D_compressed_not_matching);
9644 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
9646 gl.texImage2D(GL_TEXTURE_2D, 0, not_matching_internalformat_compressed, s_reference_width, s_reference_height, 0,
9647 not_matching_format, GL_UNSIGNED_BYTE, s_reference);
9648 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
9652 gl.getTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED, &is_compressed);
9653 GLU_EXPECT_NO_ERROR(gl.getError(), "glTetTexLevelParameteriv has failed");
9657 gl.getTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &m_not_matching_compressed_2D_format);
9658 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9660 m_not_matching_compressed_2D_size = 0;
9662 gl.getTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE,
9663 &m_not_matching_compressed_2D_size);
9664 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9667 gl.deleteTextures(1, &to_2D_compressed_not_matching);
9668 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9670 /* 3D Compressed with a non matching format. We need to do all the allocation to get the correct image size */
9671 glw::GLuint to_3D_compressed_not_matching;
9673 gl.createTextures(GL_TEXTURE_3D, 1, &to_3D_compressed_not_matching);
9674 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9676 gl.bindTexture(GL_TEXTURE_3D, to_3D_compressed_not_matching);
9677 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
9679 gl.texImage3D(GL_TEXTURE_3D, 0, not_matching_internalformat_compressed, s_reference_width, s_reference_height,
9680 s_reference_depth, 0, not_matching_format, GL_UNSIGNED_BYTE, s_reference);
9681 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage3D has failed");
9685 gl.getTexLevelParameteriv(GL_TEXTURE_3D, 0, GL_TEXTURE_COMPRESSED, &is_compressed);
9686 GLU_EXPECT_NO_ERROR(gl.getError(), "glTetTexLevelParameteriv has failed");
9690 gl.getTexLevelParameteriv(GL_TEXTURE_3D, 0, GL_TEXTURE_INTERNAL_FORMAT, &m_not_matching_compressed_3D_format);
9691 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9693 m_not_matching_compressed_3D_size = 0;
9695 gl.getTexLevelParameteriv(GL_TEXTURE_3D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE,
9696 &m_not_matching_compressed_3D_size);
9697 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9700 gl.deleteTextures(1, &to_3D_compressed_not_matching);
9701 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9704 /** @brief Test (negative) of TextureSubImage1D
9706 * @return Test result.
9708 bool SubImageErrorsTest::Test1D()
9710 /* Shortcut for GL functionality. */
9711 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
9716 /* Check that INVALID_OPERATION is generated by TextureSubImage1D if
9717 texture is not the name of an existing texture object. */
9719 gl.textureSubImage1D(m_to_invalid, 0, 0, s_reference_width, s_reference_format, s_reference_type, s_reference);
9720 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9721 "texture is not the name of an existing texture object.");
9724 /* Check that INVALID_ENUM is generated by TextureSubImage1D if format is
9725 not an accepted format constant. */
9727 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, m_format_invalid, s_reference_type, s_reference);
9728 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureSubImage1D",
9729 "format is not an accepted format constant.");
9732 /* Check that INVALID_ENUM is generated by TextureSubImage1D if type is not
9733 an accepted type constant. */
9735 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, m_type_invalid, s_reference);
9736 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureSubImage1D",
9737 "type is not an accepted type constant.");
9740 /* Check that INVALID_VALUE is generated by TextureSubImage1D if level is
9743 gl.textureSubImage1D(m_to_1D, -1, 0, s_reference_width, s_reference_format, s_reference_type, s_reference);
9744 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage1D", "level is less than 0.");
9747 /* Check that INVALID_VALUE may be generated by TextureSubImage1D if level
9748 is greater than log2 max, where max is the returned value of
9749 MAX_TEXTURE_SIZE. */
9751 gl.textureSubImage1D(m_to_1D, m_max_texture_size, 0, s_reference_width, s_reference_format, s_reference_type,
9754 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage1D",
9755 "level is greater than log2 max, where max is the returned value of MAX_TEXTURE_SIZE.");
9758 /* Check that INVALID_VALUE is generated by TextureSubImage1D if
9759 xoffset<-b, or if (xoffset+width)>(w-b), where w is the TEXTURE_WIDTH,
9760 and b is the width of the TEXTURE_BORDER of the texture image being
9761 modified. Note that w includes twice the border width. */
9763 gl.textureSubImage1D(m_to_1D, 0, -1, s_reference_width, s_reference_format, s_reference_type, s_reference);
9764 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage1D",
9765 "xoffset<-b, where b is the width of the TEXTURE_BORDER.");
9767 gl.textureSubImage1D(m_to_1D, 0, 1, s_reference_width + 1, s_reference_format, s_reference_type, s_reference);
9768 is_ok &= CheckErrorAndLog(
9769 m_context, GL_INVALID_VALUE, "glTextureSubImage1D",
9770 "(xoffset+width)>(w-b), where w is the TEXTURE_WIDTH, b is the width of the TEXTURE_BORDER.");
9773 /*Check that INVALID_VALUE is generated by TextureSubImage1D if width is less than 0. */
9775 #ifndef TURN_OFF_SUB_IMAGE_ERRORS_TEST_OF_NEGATIVE_WIDTH_HEIGHT_OR_DEPTH
9776 gl.textureSubImage1D(m_to_1D, 0, 0, -1, s_reference_format, s_reference_type, s_reference);
9777 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage1D", "width is less than 0.");
9781 /* Check that INVALID_OPERATION is generated by TextureSubImage1D if type
9782 is one of UNSIGNED_BYTE_3_3_2, UNSIGNED_BYTE_2_3_3_REV,
9783 UNSIGNED_SHORT_5_6_5, or UNSIGNED_SHORT_5_6_5_REV and format is not RGB. */
9785 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_BYTE_3_3_2, s_reference);
9786 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9787 "type is UNSIGNED_BYTE_3_3_2 and format is not RGB.");
9789 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_BYTE_2_3_3_REV,
9791 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9792 "type is UNSIGNED_BYTE_2_3_3_REV and format is not RGB.");
9794 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_SHORT_5_6_5,
9796 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9797 "type is UNSIGNED_SHORT_5_6_5 and format is not RGB.");
9799 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_SHORT_5_6_5_REV,
9801 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9802 "type is UNSIGNED_SHORT_5_6_5_REV and format is not RGB.");
9805 /* Check that INVALID_OPERATION is generated by TextureSubImage1D if type
9806 is one of UNSIGNED_SHORT_4_4_4_4, UNSIGNED_SHORT_4_4_4_4_REV,
9807 UNSIGNED_SHORT_5_5_5_1, UNSIGNED_SHORT_1_5_5_5_REV,
9808 UNSIGNED_INT_8_8_8_8, UNSIGNED_INT_8_8_8_8_REV, UNSIGNED_INT_10_10_10_2,
9809 or UNSIGNED_INT_2_10_10_10_REV and format is neither RGBA nor BGRA. */
9811 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_SHORT_4_4_4_4,
9813 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9814 "type is UNSIGNED_SHORT_4_4_4_4 and format is neither RGBA nor BGRA.");
9816 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_SHORT_4_4_4_4_REV,
9818 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9819 "type is UNSIGNED_SHORT_4_4_4_4_REV and format is neither RGBA nor BGRA.");
9821 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_SHORT_5_5_5_1,
9823 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9824 "type is UNSIGNED_SHORT_5_5_5_1 and format is neither RGBA nor BGRA.");
9826 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_SHORT_1_5_5_5_REV,
9828 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9829 "type is UNSIGNED_SHORT_1_5_5_5_REV and format is neither RGBA nor BGRA.");
9831 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_INT_8_8_8_8,
9833 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9834 "type is UNSIGNED_INT_8_8_8_8 and format is neither RGBA nor BGRA.");
9836 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_INT_8_8_8_8_REV,
9838 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9839 "type is UNSIGNED_INT_8_8_8_8_REV and format is neither RGBA nor BGRA.");
9841 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_INT_10_10_10_2,
9843 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9844 "type is UNSIGNED_INT_10_10_10_2 and format is neither RGBA nor BGRA.");
9846 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_INT_2_10_10_10_REV,
9848 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9849 "type is UNSIGNED_INT_2_10_10_10_REV and format is neither RGBA nor BGRA.");
9852 /* Check that INVALID_OPERATION is generated by TextureSubImage1D if a
9853 non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
9854 and the buffer object's data store is currently mapped. */
9856 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
9857 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9859 gl.mapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_READ_WRITE);
9861 if (GL_NO_ERROR == gl.getError())
9863 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, s_reference_type, NULL);
9864 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9865 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and "
9866 "the buffer object's data store is currently mapped.");
9868 gl.unmapBuffer(GL_PIXEL_UNPACK_BUFFER);
9869 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9871 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
9872 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9876 /* Check that INVALID_OPERATION is generated by TextureSubImage1D if a
9877 non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
9878 and the data would be unpacked from the buffer object such that the
9879 memory reads required would exceed the data store size. */
9881 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
9882 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9884 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, s_reference_type,
9885 (glw::GLubyte*)NULL + s_reference_size * 2);
9886 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9887 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and the "
9888 "data would be unpacked from the buffer object such that the memory reads required "
9889 "would exceed the data store size.");
9891 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
9892 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9895 /* Check that INVALID_OPERATION is generated by TextureSubImage1D if a
9896 non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
9897 and pixels is not evenly divisible into the number of bytes needed to
9898 store in memory a datum indicated by type. */
9900 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
9901 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9903 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, s_reference_type,
9904 (glw::GLubyte*)NULL + 1);
9905 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9906 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and pixels "
9907 "is not evenly divisible into the number of bytes needed to store in memory a datum "
9908 "indicated by type.");
9910 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
9911 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9917 /** @brief Test (negative) of TextureSubImage2D
9919 * @return Test result.
9921 bool SubImageErrorsTest::Test2D()
9923 /* Shortcut for GL functionality. */
9924 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
9929 /* Check that INVALID_OPERATION is generated by TextureSubImage2D if
9930 texture is not the name of an existing texture object. */
9932 gl.textureSubImage2D(m_to_invalid, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9933 s_reference_type, s_reference);
9934 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9935 "texture is not the name of an existing texture object.");
9938 /* Check that INVALID_ENUM is generated by TextureSubImage2D if format is
9939 not an accepted format constant. */
9941 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, m_format_invalid,
9942 s_reference_type, s_reference);
9943 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureSubImage2D",
9944 "format is not an accepted format constant.");
9947 /* Check that INVALID_ENUM is generated by TextureSubImage2D if type is not
9948 an accepted type constant. */
9950 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9951 m_type_invalid, s_reference);
9952 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureSubImage2D",
9953 "type is not an accepted type constant.");
9956 /* Check that INVALID_VALUE is generated by TextureSubImage2D if level is
9959 gl.textureSubImage2D(m_to_2D, -1, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9960 s_reference_type, s_reference);
9961 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage2D", "level is less than 0.");
9964 /* Check that INVALID_VALUE may be generated by TextureSubImage2D if level
9965 is greater than log2 max, where max is the returned value of
9966 MAX_TEXTURE_SIZE. */
9968 gl.textureSubImage2D(m_to_2D, m_max_texture_size, 0, 0, s_reference_width, s_reference_height,
9969 s_reference_format, s_reference_type, s_reference);
9971 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage2D",
9972 "level is greater than log2 max, where max is the returned value of MAX_TEXTURE_SIZE.");
9975 /* Check that INVALID_VALUE may be generated by TextureSubImage2D if level
9976 is greater than log2 max, where max is the returned value of
9978 Check that INVALID_VALUE is generated by TextureSubImage2D if
9979 xoffset<-b, (xoffset+width)>(w-b), yoffset<-b, or
9980 (yoffset+height)>(h-b), where w is the TEXTURE_WIDTH, h is the
9981 TEXTURE_HEIGHT, and b is the border width of the texture image being
9982 modified. Note that w and h include twice the border width. */
9984 gl.textureSubImage2D(m_to_2D, 0, -1, 0, s_reference_width, s_reference_height, s_reference_format,
9985 s_reference_type, s_reference);
9986 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage2D",
9987 "xoffset<-b, where b is the width of the TEXTURE_BORDER.");
9989 gl.textureSubImage2D(m_to_2D, 0, 1, 0, s_reference_width + 1, s_reference_height, s_reference_format,
9990 s_reference_type, s_reference);
9991 is_ok &= CheckErrorAndLog(
9992 m_context, GL_INVALID_VALUE, "glTextureSubImage2D",
9993 "(xoffset+width)>(w-b), where w is the TEXTURE_WIDTH, b is the width of the TEXTURE_BORDER.");
9995 gl.textureSubImage2D(m_to_2D, 0, 0, -1, s_reference_width, s_reference_height, s_reference_format,
9996 s_reference_type, s_reference);
9997 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage2D",
9998 "yoffset<-b, where b is the height of the TEXTURE_BORDER.");
10000 gl.textureSubImage2D(m_to_2D, 0, 0, 1, s_reference_width + 1, s_reference_height, s_reference_format,
10001 s_reference_type, s_reference);
10002 is_ok &= CheckErrorAndLog(
10003 m_context, GL_INVALID_VALUE, "glTextureSubImage2D",
10004 "(yoffset+height)>(h-b), where h is the TEXTURE_HEIGHT, b is the width of the TEXTURE_BORDER.");
10007 /*Check that INVALID_VALUE is generated by TextureSubImage2D if width or height is less than 0. */
10009 #ifndef TURN_OFF_SUB_IMAGE_ERRORS_TEST_OF_NEGATIVE_WIDTH_HEIGHT_OR_DEPTH
10010 gl.textureSubImage2D(m_to_2D, 0, 0, 0, -1, s_reference_height, s_reference_format, s_reference_type,
10012 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage2D", "width is less than 0.");
10014 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, -1, s_reference_format, s_reference_type,
10016 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage2D", "height is less than 0.");
10020 /* Check that INVALID_OPERATION is generated by TextureSubImage2D if type
10021 is one of UNSIGNED_BYTE_3_3_2, UNSIGNED_BYTE_2_3_3_REV,
10022 UNSIGNED_SHORT_5_6_5, or UNSIGNED_SHORT_5_6_5_REV and format is not RGB. */
10024 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
10025 GL_UNSIGNED_BYTE_3_3_2, s_reference);
10026 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
10027 "type is UNSIGNED_BYTE_3_3_2 and format is not RGB.");
10029 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
10030 GL_UNSIGNED_BYTE_2_3_3_REV, s_reference);
10031 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
10032 "type is UNSIGNED_BYTE_2_3_3_REV and format is not RGB.");
10034 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
10035 GL_UNSIGNED_SHORT_5_6_5, s_reference);
10036 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
10037 "type is UNSIGNED_SHORT_5_6_5 and format is not RGB.");
10039 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
10040 GL_UNSIGNED_SHORT_5_6_5_REV, s_reference);
10041 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
10042 "type is UNSIGNED_SHORT_5_6_5_REV and format is not RGB.");
10045 /* Check that INVALID_OPERATION is generated by TextureSubImage2D if type
10046 is one of UNSIGNED_SHORT_4_4_4_4, UNSIGNED_SHORT_4_4_4_4_REV,
10047 UNSIGNED_SHORT_5_5_5_1, UNSIGNED_SHORT_1_5_5_5_REV,
10048 UNSIGNED_INT_8_8_8_8, UNSIGNED_INT_8_8_8_8_REV, UNSIGNED_INT_10_10_10_2,
10049 or UNSIGNED_INT_2_10_10_10_REV and format is neither RGBA nor BGRA. */
10051 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
10052 GL_UNSIGNED_SHORT_4_4_4_4, s_reference);
10053 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
10054 "type is UNSIGNED_SHORT_4_4_4_4 and format is neither RGBA nor BGRA.");
10056 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
10057 GL_UNSIGNED_SHORT_4_4_4_4_REV, s_reference);
10058 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
10059 "type is UNSIGNED_SHORT_4_4_4_4_REV and format is neither RGBA nor BGRA.");
10061 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
10062 GL_UNSIGNED_SHORT_5_5_5_1, s_reference);
10063 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
10064 "type is UNSIGNED_SHORT_5_5_5_1 and format is neither RGBA nor BGRA.");
10066 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
10067 GL_UNSIGNED_SHORT_1_5_5_5_REV, s_reference);
10068 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
10069 "type is UNSIGNED_SHORT_1_5_5_5_REV and format is neither RGBA nor BGRA.");
10071 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
10072 GL_UNSIGNED_INT_8_8_8_8, s_reference);
10073 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
10074 "type is UNSIGNED_INT_8_8_8_8 and format is neither RGBA nor BGRA.");
10076 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
10077 GL_UNSIGNED_INT_8_8_8_8_REV, s_reference);
10078 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
10079 "type is UNSIGNED_INT_8_8_8_8_REV and format is neither RGBA nor BGRA.");
10081 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
10082 GL_UNSIGNED_INT_10_10_10_2, s_reference);
10083 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
10084 "type is UNSIGNED_INT_10_10_10_2 and format is neither RGBA nor BGRA.");
10086 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
10087 GL_UNSIGNED_INT_2_10_10_10_REV, s_reference);
10088 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
10089 "type is UNSIGNED_INT_2_10_10_10_REV and format is neither RGBA nor BGRA.");
10092 /* Check that INVALID_OPERATION is generated by TextureSubImage2D if a
10093 non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
10094 and the buffer object's data store is currently mapped. */
10096 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
10097 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10099 gl.mapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_READ_WRITE);
10101 if (GL_NO_ERROR == gl.getError())
10103 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
10104 s_reference_type, NULL);
10105 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
10106 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and "
10107 "the buffer object's data store is currently mapped.");
10109 gl.unmapBuffer(GL_PIXEL_UNPACK_BUFFER);
10110 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10112 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10113 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10117 /* Check that INVALID_OPERATION is generated by TextureSubImage2D if a
10118 non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
10119 and the data would be unpacked from the buffer object such that the
10120 memory reads required would exceed the data store size. */
10122 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
10123 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10125 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
10126 s_reference_type, (glw::GLubyte*)NULL + s_reference_size * 2);
10127 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
10128 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and the "
10129 "data would be unpacked from the buffer object such that the memory reads required "
10130 "would exceed the data store size.");
10132 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10133 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10136 /* Check that INVALID_OPERATION is generated by TextureSubImage2D if a
10137 non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
10138 and pixels is not evenly divisible into the number of bytes needed to
10139 store in memory a datum indicated by type. */
10141 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
10142 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10144 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
10145 s_reference_type, (glw::GLubyte*)NULL + 1);
10146 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
10147 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and pixels "
10148 "is not evenly divisible into the number of bytes needed to store in memory a datum "
10149 "indicated by type.");
10151 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10152 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10158 /** @brief Test (negative) of TextureSubImage3D
10160 * @return Test result.
10162 bool SubImageErrorsTest::Test3D()
10164 /* Shortcut for GL functionality. */
10165 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
10170 /* Check that INVALID_OPERATION is generated by TextureSubImage3D if
10171 texture is not the name of an existing texture object. */
10173 gl.textureSubImage3D(m_to_invalid, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10174 s_reference_format, s_reference_type, s_reference);
10175 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10176 "texture is not the name of an existing texture object.");
10179 /* Check that INVALID_ENUM is generated by TextureSubImage3D if format is
10180 not an accepted format constant. */
10182 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10183 m_format_invalid, s_reference_type, s_reference);
10184 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureSubImage3D",
10185 "format is not an accepted format constant.");
10188 /* Check that INVALID_ENUM is generated by TextureSubImage3D if type is not
10189 an accepted type constant. */
10191 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10192 s_reference_format, m_type_invalid, s_reference);
10193 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureSubImage3D",
10194 "type is not an accepted type constant.");
10197 /* Check that INVALID_VALUE is generated by TextureSubImage3D if level is
10200 gl.textureSubImage3D(m_to_3D, -1, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10201 s_reference_format, s_reference_type, s_reference);
10202 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage3D", "level is less than 0.");
10205 /* Check that INVALID_VALUE may be generated by TextureSubImage1D if level
10206 is greater than log2 max, where max is the returned value of
10207 MAX_TEXTURE_SIZE. */
10209 gl.textureSubImage3D(m_to_3D, m_max_texture_size, 0, 0, 0, s_reference_width, s_reference_height,
10210 s_reference_depth, s_reference_format, s_reference_type, s_reference);
10212 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage3D",
10213 "level is greater than log2 max, where max is the returned value of MAX_TEXTURE_SIZE.");
10216 /* Check that INVALID_VALUE is generated by TextureSubImage3D if
10217 xoffset<-b, (xoffset+width)>(w-b), yoffset<-b, or
10218 (yoffset+height)>(h-b), or zoffset<-b, or (zoffset+depth)>(d-b), where w
10219 is the TEXTURE_WIDTH, h is the TEXTURE_HEIGHT, d is the TEXTURE_DEPTH
10220 and b is the border width of the texture image being modified. Note
10221 that w, h, and d include twice the border width. */
10223 gl.textureSubImage3D(m_to_3D, 0, -1, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10224 s_reference_format, s_reference_type, s_reference);
10225 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage3D",
10226 "xoffset<-b, where b is the width of the TEXTURE_BORDER.");
10228 gl.textureSubImage3D(m_to_3D, 0, 1, 0, 0, s_reference_width + 1, s_reference_height, s_reference_depth,
10229 s_reference_format, s_reference_type, s_reference);
10230 is_ok &= CheckErrorAndLog(
10231 m_context, GL_INVALID_VALUE, "glTextureSubImage3D",
10232 "(xoffset+width)>(w-b), where w is the TEXTURE_WIDTH, b is the width of the TEXTURE_BORDER.");
10234 gl.textureSubImage3D(m_to_3D, 0, 0, -1, 0, s_reference_width, s_reference_height, s_reference_depth,
10235 s_reference_format, s_reference_type, s_reference);
10236 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage3D",
10237 "yoffset<-b, where b is the width of the TEXTURE_BORDER.");
10239 gl.textureSubImage3D(m_to_3D, 0, 0, 1, 0, s_reference_width + 1, s_reference_height, s_reference_depth,
10240 s_reference_format, s_reference_type, s_reference);
10241 is_ok &= CheckErrorAndLog(
10242 m_context, GL_INVALID_VALUE, "glTextureSubImage3D",
10243 "(yoffset+height)>(h-b), where h is the TEXTURE_HEIGHT, b is the width of the TEXTURE_BORDER.");
10245 gl.textureSubImage3D(m_to_3D, 0, 0, 0, -1, s_reference_width, s_reference_height, s_reference_depth,
10246 s_reference_format, s_reference_type, s_reference);
10247 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage3D",
10248 "zoffset<-b, where b is the depth of the TEXTURE_BORDER.");
10250 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 1, s_reference_width + 1, s_reference_height, s_reference_depth,
10251 s_reference_format, s_reference_type, s_reference);
10252 is_ok &= CheckErrorAndLog(
10253 m_context, GL_INVALID_VALUE, "glTextureSubImage3D",
10254 "(zoffset+width)>(d-b), where d is the TEXTURE_DEPTH, b is the width of the TEXTURE_BORDER.");
10257 /*Check that INVALID_VALUE is generated by TextureSubImage3D if width or height or depth is less than 0. */
10259 #ifndef TURN_OFF_SUB_IMAGE_ERRORS_TEST_OF_NEGATIVE_WIDTH_HEIGHT_OR_DEPTH
10260 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, -1, s_reference_height, s_reference_depth, s_reference_format,
10261 s_reference_type, s_reference);
10262 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage1D", "width is less than 0.");
10264 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, -1, s_reference_depth, s_reference_format,
10265 s_reference_type, s_reference);
10266 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage1D", "height is less than 0.");
10268 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, -1, s_reference_format,
10269 s_reference_type, s_reference);
10270 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage1D", "depth is less than 0.");
10274 /* Check that INVALID_OPERATION is generated by TextureSubImage3D if type
10275 is one of UNSIGNED_BYTE_3_3_2, UNSIGNED_BYTE_2_3_3_REV,
10276 UNSIGNED_SHORT_5_6_5, or UNSIGNED_SHORT_5_6_5_REV and format is not RGB. */
10278 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10279 s_reference_format, GL_UNSIGNED_BYTE_3_3_2, s_reference);
10280 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10281 "type is UNSIGNED_BYTE_3_3_2 and format is not RGB.");
10283 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10284 s_reference_format, GL_UNSIGNED_BYTE_2_3_3_REV, s_reference);
10285 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10286 "type is UNSIGNED_BYTE_2_3_3_REV and format is not RGB.");
10288 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10289 s_reference_format, GL_UNSIGNED_SHORT_5_6_5, s_reference);
10290 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10291 "type is UNSIGNED_SHORT_5_6_5 and format is not RGB.");
10293 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10294 s_reference_format, GL_UNSIGNED_SHORT_5_6_5_REV, s_reference);
10295 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10296 "type is UNSIGNED_SHORT_5_6_5_REV and format is not RGB.");
10299 /* Check that INVALID_OPERATION is generated by TextureSubImage3D if type
10300 is one of UNSIGNED_SHORT_4_4_4_4, UNSIGNED_SHORT_4_4_4_4_REV,
10301 UNSIGNED_SHORT_5_5_5_1, UNSIGNED_SHORT_1_5_5_5_REV,
10302 UNSIGNED_INT_8_8_8_8, UNSIGNED_INT_8_8_8_8_REV, UNSIGNED_INT_10_10_10_2,
10303 or UNSIGNED_INT_2_10_10_10_REV and format is neither RGBA nor BGRA. */
10305 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10306 s_reference_format, GL_UNSIGNED_SHORT_4_4_4_4, s_reference);
10307 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10308 "type is UNSIGNED_SHORT_4_4_4_4 and format is neither RGBA nor BGRA.");
10310 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10311 s_reference_format, GL_UNSIGNED_SHORT_4_4_4_4_REV, s_reference);
10312 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10313 "type is UNSIGNED_SHORT_4_4_4_4_REV and format is neither RGBA nor BGRA.");
10315 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10316 s_reference_format, GL_UNSIGNED_SHORT_5_5_5_1, s_reference);
10317 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10318 "type is UNSIGNED_SHORT_5_5_5_1 and format is neither RGBA nor BGRA.");
10320 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10321 s_reference_format, GL_UNSIGNED_SHORT_1_5_5_5_REV, s_reference);
10322 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10323 "type is UNSIGNED_SHORT_1_5_5_5_REV and format is neither RGBA nor BGRA.");
10325 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10326 s_reference_format, GL_UNSIGNED_INT_8_8_8_8, s_reference);
10327 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10328 "type is UNSIGNED_INT_8_8_8_8 and format is neither RGBA nor BGRA.");
10330 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10331 s_reference_format, GL_UNSIGNED_INT_8_8_8_8_REV, s_reference);
10332 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10333 "type is UNSIGNED_INT_8_8_8_8_REV and format is neither RGBA nor BGRA.");
10335 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10336 s_reference_format, GL_UNSIGNED_INT_10_10_10_2, s_reference);
10337 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10338 "type is UNSIGNED_INT_10_10_10_2 and format is neither RGBA nor BGRA.");
10340 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10341 s_reference_format, GL_UNSIGNED_INT_2_10_10_10_REV, s_reference);
10342 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10343 "type is UNSIGNED_INT_2_10_10_10_REV and format is neither RGBA nor BGRA.");
10346 /* Check that INVALID_OPERATION is generated by TextureSubImage3D if a
10347 non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
10348 and the buffer object's data store is currently mapped. */
10350 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
10351 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10353 gl.mapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_READ_WRITE);
10355 if (GL_NO_ERROR == gl.getError())
10357 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10358 s_reference_format, s_reference_type, NULL);
10359 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10360 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and "
10361 "the buffer object's data store is currently mapped.");
10363 gl.unmapBuffer(GL_PIXEL_UNPACK_BUFFER);
10364 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10366 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10367 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10371 /* Check that INVALID_OPERATION is generated by TextureSubImage3D if a
10372 non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
10373 and the data would be unpacked from the buffer object such that the
10374 memory reads required would exceed the data store size. */
10376 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
10377 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10379 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10380 s_reference_format, s_reference_type, (glw::GLubyte*)NULL + s_reference_size * 2);
10381 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10382 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and the "
10383 "data would be unpacked from the buffer object such that the memory reads required "
10384 "would exceed the data store size.");
10386 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10387 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10390 /* Check that INVALID_OPERATION is generated by TextureSubImage3D if a
10391 non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
10392 and pixels is not evenly divisible into the number of bytes needed to
10393 store in memory a datum indicated by type. */
10395 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
10396 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10398 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10399 s_reference_format, s_reference_type, (glw::GLubyte*)NULL + 1);
10400 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10401 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and pixels "
10402 "is not evenly divisible into the number of bytes needed to store in memory a datum "
10403 "indicated by type.");
10405 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10406 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10412 /** @brief Test (negative) of TextureSubImage1DCompressed
10414 * @return Test result.
10416 bool SubImageErrorsTest::Test1DCompressed()
10418 /* Shortcut for GL functionality. */
10419 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
10424 /* Do tests only if compressed 1D textures are supported. */
10425 if (DE_NULL != m_reference_compressed_1D)
10427 /* Check that INVALID_OPERATION is generated by CompressedTextureSubImage1D
10428 if texture is not the name of an existing texture object. */
10430 gl.compressedTextureSubImage1D(m_to_invalid, 0, 0, s_reference_width, m_reference_compressed_1D_format,
10431 m_reference_compressed_1D_size, m_reference_compressed_1D);
10432 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage1D",
10433 "texture is not the name of an existing texture object.");
10436 /* Check that INVALID_ENUM is generated by CompressedTextureSubImage1D if
10437 internalformat is not one of the generic compressed internal formats:
10438 COMPRESSED_RED, COMPRESSED_RG, COMPRESSED_RGB, COMPRESSED_RGBA.
10439 COMPRESSED_SRGB, or COMPRESSED_SRGB_ALPHA. */
10441 /* GL_COMPRESSED_RG_RGTC2 is not 1D as specification says. */
10442 gl.compressedTextureSubImage1D(m_to_1D_compressed, 0, 0, s_reference_width, GL_COMPRESSED_RG_RGTC2,
10443 m_reference_compressed_1D_size, m_reference_compressed_1D);
10444 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glCompressedTextureSubImage1D",
10445 "internalformat is of the generic compressed internal formats: COMPRESSED_RED, "
10446 "COMPRESSED_RG, COMPRESSED_RGB, COMPRESSED_RGBA. COMPRESSED_SRGB, or "
10447 "COMPRESSED_SRGB_ALPHA.");
10450 /* Check that INVALID_OPERATION is generated if format does not match the
10451 internal format of the texture image being modified, since these
10452 commands do not provide for image format conversion. */
10454 gl.compressedTextureSubImage1D(m_to_1D_compressed, 0, 0, s_reference_width,
10455 m_not_matching_compressed_1D_format, m_not_matching_compressed_1D_size,
10456 m_reference_compressed_1D);
10457 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage1D",
10458 "format does not match the internal format of the texture image being modified, "
10459 "since these commands do not provide for image format conversion.");
10462 /* Check that INVALID_VALUE is generated by CompressedTextureSubImage1D if
10463 imageSize is not consistent with the format, dimensions, and contents of
10464 the specified compressed image data. */
10466 gl.compressedTextureSubImage1D(m_to_1D_compressed, 0, 0, s_reference_width,
10467 m_reference_compressed_1D_format, m_reference_compressed_1D_size - 1,
10468 m_reference_compressed_1D);
10469 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCompressedTextureSubImage1D",
10470 "imageSize is not consistent with the format, dimensions, and contents of the "
10471 "specified compressed image data.");
10474 /* Check that INVALID_OPERATION is generated by CompressedTextureSubImage1D
10475 if a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER
10476 target and the buffer object's data store is currently mapped. */
10478 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
10479 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10481 gl.mapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_READ_WRITE);
10483 if (GL_NO_ERROR == gl.getError())
10485 gl.compressedTextureSubImage1D(m_to_1D_compressed, 0, 0, s_reference_width,
10486 m_reference_compressed_1D_format, m_reference_compressed_1D_size, NULL);
10487 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage1D",
10488 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target "
10489 "and the buffer object's data store is currently mapped.");
10491 gl.unmapBuffer(GL_PIXEL_UNPACK_BUFFER);
10492 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10494 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10495 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10499 /* Check that INVALID_OPERATION is generated by CompressedTextureSubImage1D
10500 if a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER
10501 target and the data would be unpacked from the buffer object such that
10502 the memory reads required would exceed the data store size. */
10504 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
10505 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10507 gl.compressedTextureSubImage1D(m_to_1D_compressed, 0, 0, s_reference_width,
10508 m_reference_compressed_1D_format, m_reference_compressed_1D_size,
10509 (glw::GLubyte*)NULL + s_reference_size * 2);
10510 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage1D",
10511 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and "
10512 "the buffer object's data store is currently mapped.");
10514 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10515 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10522 /** @brief Test (negative) of TextureSubImage2DCompressed
10524 * @return Test result.
10526 bool SubImageErrorsTest::Test2DCompressed()
10528 /* Shortcut for GL functionality. */
10529 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
10534 /* Do tests only if compressed 2D textures are supported. */
10535 if (DE_NULL != m_reference_compressed_2D)
10537 /* Check that INVALID_OPERATION is generated by CompressedTextureSubImage2D
10538 if texture is not the name of an existing texture object. */
10540 gl.compressedTextureSubImage2D(m_to_invalid, 0, 0, 0, s_reference_width, s_reference_height,
10541 m_reference_compressed_2D_format, m_reference_compressed_2D_size,
10542 m_reference_compressed_2D);
10543 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage2D",
10544 "texture is not the name of an existing texture object.");
10547 /* Check that INVALID_ENUM is generated by CompressedTextureSubImage2D if
10548 internalformat is of the generic compressed internal formats:
10549 COMPRESSED_RED, COMPRESSED_RG, COMPRESSED_RGB, COMPRESSED_RGBA.
10550 COMPRESSED_SRGB, or COMPRESSED_SRGB_ALPHA. */
10552 gl.compressedTextureSubImage2D(m_to_2D_compressed, 0, 0, 0, s_reference_width, s_reference_height,
10553 GL_COMPRESSED_RG, m_reference_compressed_2D_size, m_reference_compressed_2D);
10554 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glCompressedTextureSubImage2D",
10555 "internalformat is of the generic compressed internal formats: COMPRESSED_RED, "
10556 "COMPRESSED_RG, COMPRESSED_RGB, COMPRESSED_RGBA. COMPRESSED_SRGB, or "
10557 "COMPRESSED_SRGB_ALPHA.");
10560 /* Check that INVALID_OPERATION is generated if format does not match the
10561 internal format of the texture image being modified, since these
10562 commands do not provide for image format conversion. */
10564 gl.compressedTextureSubImage2D(m_to_2D_compressed, 0, 0, 0, s_reference_width, s_reference_height,
10565 m_not_matching_compressed_2D_format, m_not_matching_compressed_2D_size,
10566 m_reference_compressed_2D);
10567 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage2D",
10568 "format does not match the internal format of the texture image being modified, "
10569 "since these commands do not provide for image format conversion.");
10572 /* Check that INVALID_VALUE is generated by CompressedTextureSubImage2D if
10573 imageSize is not consistent with the format, dimensions, and contents of
10574 the specified compressed image data. */
10576 gl.compressedTextureSubImage2D(m_to_2D_compressed, 0, 0, 0, s_reference_width, s_reference_height,
10577 m_reference_compressed_2D_format, m_reference_compressed_2D_size - 1,
10578 m_reference_compressed_2D);
10579 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCompressedTextureSubImage2D",
10580 "imageSize is not consistent with the format, dimensions, and contents of the "
10581 "specified compressed image data.");
10584 /* Check that INVALID_OPERATION is generated by CompressedTextureSubImage2D
10585 if a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER
10586 target and the buffer object's data store is currently mapped. */
10588 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
10589 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10591 gl.mapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_READ_WRITE);
10593 if (GL_NO_ERROR == gl.getError())
10595 gl.compressedTextureSubImage2D(m_to_2D_compressed, 0, 0, 0, s_reference_width, s_reference_height,
10596 m_reference_compressed_2D_format, m_reference_compressed_2D_size, NULL);
10597 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage2D",
10598 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target "
10599 "and the buffer object's data store is currently mapped.");
10601 gl.unmapBuffer(GL_PIXEL_UNPACK_BUFFER);
10602 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10604 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10605 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10609 /* Check that INVALID_OPERATION is generated by CompressedTextureSubImage2D
10610 if a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER
10611 target and the data would be unpacked from the buffer object such that
10612 the memory reads required would exceed the data store size. */
10614 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
10615 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10617 gl.compressedTextureSubImage2D(m_to_2D_compressed, 0, 0, 0, s_reference_width, s_reference_height,
10618 m_reference_compressed_2D_format, m_reference_compressed_2D_size,
10619 (glw::GLubyte*)NULL + s_reference_size * 2);
10620 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage2D",
10621 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and "
10622 "the buffer object's data store is currently mapped.");
10624 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10625 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10628 /* Check that INVALID_OPERATION is generated by CompressedTextureSubImage2D
10629 if the effective target is TEXTURE_RECTANGLE. */
10631 m_reference_compressed_rectangle) /* Do test only if rectangle compressed texture is supported by the implementation. */
10633 gl.compressedTextureSubImage2D(m_to_rectangle_compressed, 0, 0, 0, s_reference_width, s_reference_height,
10634 m_reference_compressed_rectangle_format,
10635 m_reference_compressed_rectangle_size, m_reference_compressed_rectangle);
10637 if (m_context.getContextInfo().isExtensionSupported("GL_NV_texture_rectangle_compressed"))
10639 is_ok &= CheckErrorAndLog(m_context, GL_NO_ERROR, "glCompressedTextureSubImage2D",
10640 "a rectangle texture object is used with this function.");
10644 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage2D",
10645 "a rectangle texture object is used with this function.");
10653 /** @brief Test (negative) of TextureSubImage3DCompressed
10655 * @return Test result.
10657 bool SubImageErrorsTest::Test3DCompressed()
10659 /* Shortcut for GL functionality. */
10660 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
10665 /* Do tests only if compressed 3D textures are supported. */
10666 if (DE_NULL != m_reference_compressed_3D)
10668 /* Check that INVALID_OPERATION is generated by CompressedTextureSubImage3D
10669 if texture is not the name of an existing texture object. */
10671 gl.compressedTextureSubImage3D(m_to_invalid, 0, 0, 0, 0, s_reference_width, s_reference_height,
10672 s_reference_depth, m_reference_compressed_3D_format,
10673 m_reference_compressed_3D_size, m_reference_compressed_3D);
10674 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage3D",
10675 "texture is not the name of an existing texture object.");
10678 /* Check that INVALID_ENUM is generated by CompressedTextureSubImage3D if
10679 internalformat is of the generic compressed internal formats:
10680 COMPRESSED_RED, COMPRESSED_RG, COMPRESSED_RGB, COMPRESSED_RGBA.
10681 COMPRESSED_SRGB, or COMPRESSED_SRGB_ALPHA. */
10683 gl.compressedTextureSubImage3D(m_to_3D_compressed, 0, 0, 0, 0, s_reference_width, s_reference_height,
10684 s_reference_depth, GL_COMPRESSED_RG, m_reference_compressed_3D_size,
10685 m_reference_compressed_3D);
10686 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glCompressedTextureSubImage3D",
10687 "internalformat is of the generic compressed internal formats: COMPRESSED_RED, "
10688 "COMPRESSED_RG, COMPRESSED_RGB, COMPRESSED_RGBA. COMPRESSED_SRGB, or "
10689 "COMPRESSED_SRGB_ALPHA.");
10692 /* Check that INVALID_OPERATION is generated if format does not match the
10693 internal format of the texture image being modified, since these
10694 commands do not provide for image format conversion. */
10696 gl.compressedTextureSubImage3D(m_to_3D_compressed, 0, 0, 0, 0, s_reference_width, s_reference_height,
10697 s_reference_depth, m_not_matching_compressed_3D_format,
10698 m_not_matching_compressed_3D_size, m_reference_compressed_3D);
10699 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage3D",
10700 "format does not match the internal format of the texture image being modified, "
10701 "since these commands do not provide for image format conversion.");
10704 /* Check that INVALID_VALUE is generated by CompressedTextureSubImage3D if
10705 imageSize is not consistent with the format, dimensions, and contents of
10706 the specified compressed image data. */
10708 gl.compressedTextureSubImage3D(m_to_3D_compressed, 0, 0, 0, 0, s_reference_width, s_reference_height,
10709 s_reference_depth, m_reference_compressed_3D_format,
10710 m_reference_compressed_3D_size - 1, m_reference_compressed_3D);
10711 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCompressedTextureSubImage3D",
10712 "imageSize is not consistent with the format, dimensions, and contents of the "
10713 "specified compressed image data.");
10716 /* Check that INVALID_OPERATION is generated by CompressedTextureSubImage3D
10717 if a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER
10718 target and the buffer object's data store is currently mapped. */
10720 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
10721 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10723 gl.mapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_READ_WRITE);
10725 if (GL_NO_ERROR == gl.getError())
10727 gl.compressedTextureSubImage3D(m_to_3D_compressed, 0, 0, 0, 0, s_reference_width, s_reference_height,
10728 s_reference_depth, m_reference_compressed_3D_format,
10729 m_reference_compressed_3D_size, NULL);
10730 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage3D",
10731 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target "
10732 "and the buffer object's data store is currently mapped.");
10734 gl.unmapBuffer(GL_PIXEL_UNPACK_BUFFER);
10735 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10737 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10738 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10742 /* Check that INVALID_OPERATION is generated by CompressedTextureSubImage3D
10743 if a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER
10744 target and the data would be unpacked from the buffer object such that
10745 the memory reads required would exceed the data store size. */
10747 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
10748 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10750 gl.compressedTextureSubImage3D(m_to_3D_compressed, 0, 0, 0, 0, s_reference_width, s_reference_height,
10751 s_reference_depth, m_reference_compressed_3D_format,
10752 m_reference_compressed_3D_size, (glw::GLubyte*)NULL + s_reference_size * 2);
10753 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage3D",
10754 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and "
10755 "the buffer object's data store is currently mapped.");
10757 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10758 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10765 /** @brief Clean GL objects, test variables and GL errors.
10767 void SubImageErrorsTest::Clean()
10769 /* Shortcut for GL functionality. */
10770 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
10775 gl.deleteTextures(1, &m_to_1D_empty);
10782 gl.deleteTextures(1, &m_to_2D_empty);
10789 gl.deleteTextures(1, &m_to_3D_empty);
10796 gl.deleteTextures(1, &m_to_1D);
10803 gl.deleteTextures(1, &m_to_2D);
10810 gl.deleteTextures(1, &m_to_3D);
10815 if (m_to_1D_compressed)
10817 gl.deleteTextures(1, &m_to_1D_compressed);
10819 m_to_1D_compressed = 0;
10822 if (m_to_2D_compressed)
10824 gl.deleteTextures(1, &m_to_2D_compressed);
10826 m_to_2D_compressed = 0;
10829 if (m_to_3D_compressed)
10831 gl.deleteTextures(1, &m_to_3D_compressed);
10833 m_to_3D_compressed = 0;
10836 if (m_to_rectangle_compressed)
10838 gl.deleteTextures(1, &m_to_rectangle_compressed);
10840 m_to_rectangle_compressed = 0;
10845 gl.deleteBuffers(1, &m_bo);
10851 m_format_invalid = 0;
10852 m_type_invalid = 0;
10853 m_max_texture_size = 1;
10855 if (DE_NULL != m_reference_compressed_1D)
10857 delete[] m_reference_compressed_1D;
10859 m_reference_compressed_1D = NULL;
10862 if (DE_NULL != m_reference_compressed_2D)
10864 delete[] m_reference_compressed_2D;
10866 m_reference_compressed_2D = NULL;
10869 if (DE_NULL != m_reference_compressed_3D)
10871 delete[] m_reference_compressed_3D;
10873 m_reference_compressed_3D = NULL;
10876 if (DE_NULL != m_reference_compressed_rectangle)
10878 delete[] m_reference_compressed_rectangle;
10880 m_reference_compressed_rectangle = NULL;
10883 m_reference_compressed_1D_format = 0;
10884 m_reference_compressed_2D_format = 0;
10885 m_reference_compressed_3D_format = 0;
10886 m_reference_compressed_rectangle_format = 0;
10887 m_reference_compressed_1D_size = 0;
10888 m_reference_compressed_2D_size = 0;
10889 m_reference_compressed_3D_size = 0;
10890 m_reference_compressed_rectangle_size = 0;
10891 m_not_matching_compressed_1D_format = 0;
10892 m_not_matching_compressed_1D_size = 0;
10893 m_not_matching_compressed_2D_format = 0;
10894 m_not_matching_compressed_2D_size = 0;
10895 m_not_matching_compressed_3D_format = 0;
10896 m_not_matching_compressed_3D_size = 0;
10898 while (GL_NO_ERROR != gl.getError())
10902 /** Reference data */
10903 const glw::GLushort SubImageErrorsTest::s_reference[] = {
10904 0x0, 0x0, 0x0, 0xff, 0x7f, 0x7f, 0x7f, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff,
10905 0x88, 0x0, 0x15, 0xff, 0xed, 0x1c, 0x24, 0xff, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x0, 0xff,
10906 0xc8, 0xbf, 0xe7, 0xff, 0x70, 0x92, 0xbe, 0xff, 0x99, 0xd9, 0xea, 0xff, 0xb5, 0xe6, 0x1d, 0xff,
10907 0xa3, 0x49, 0xa4, 0xff, 0x3f, 0x48, 0xcc, 0xff, 0x0, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0xff,
10909 0x0, 0x0, 0x0, 0xff, 0x7f, 0x7f, 0x7f, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff,
10910 0x88, 0x0, 0x15, 0xff, 0xed, 0x1c, 0x24, 0xff, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x0, 0xff,
10911 0xc8, 0xbf, 0xe7, 0xff, 0x70, 0x92, 0xbe, 0xff, 0x99, 0xd9, 0xea, 0xff, 0xb5, 0xe6, 0x1d, 0xff,
10912 0xa3, 0x49, 0xa4, 0xff, 0x3f, 0x48, 0xcc, 0xff, 0x0, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0xff,
10914 0x0, 0x0, 0x0, 0xff, 0x7f, 0x7f, 0x7f, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff,
10915 0x88, 0x0, 0x15, 0xff, 0xed, 0x1c, 0x24, 0xff, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x0, 0xff,
10916 0xc8, 0xbf, 0xe7, 0xff, 0x70, 0x92, 0xbe, 0xff, 0x99, 0xd9, 0xea, 0xff, 0xb5, 0xe6, 0x1d, 0xff,
10917 0xa3, 0x49, 0xa4, 0xff, 0x3f, 0x48, 0xcc, 0xff, 0x0, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0xff,
10919 0x0, 0x0, 0x0, 0xff, 0x7f, 0x7f, 0x7f, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff,
10920 0x88, 0x0, 0x15, 0xff, 0xed, 0x1c, 0x24, 0xff, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x0, 0xff,
10921 0xc8, 0xbf, 0xe7, 0xff, 0x70, 0x92, 0xbe, 0xff, 0x99, 0xd9, 0xea, 0xff, 0xb5, 0xe6, 0x1d, 0xff,
10922 0xa3, 0x49, 0xa4, 0xff, 0x3f, 0x48, 0xcc, 0xff, 0x0, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0xff
10925 /** Reference data parameters. */
10926 const glw::GLuint SubImageErrorsTest::s_reference_size = sizeof(s_reference);
10927 const glw::GLuint SubImageErrorsTest::s_reference_width = 4;
10928 const glw::GLuint SubImageErrorsTest::s_reference_height = 4;
10929 const glw::GLuint SubImageErrorsTest::s_reference_depth = 4;
10930 const glw::GLenum SubImageErrorsTest::s_reference_internalformat = GL_RG8;
10931 const glw::GLenum SubImageErrorsTest::s_reference_internalformat_compressed = GL_COMPRESSED_RG;
10932 const glw::GLenum SubImageErrorsTest::s_reference_format = GL_RG; /* !Must not be a RGB, RGBA, or BGRA */
10933 const glw::GLenum SubImageErrorsTest::s_reference_type = GL_UNSIGNED_SHORT;
10935 /******************************** Copy Errors Test Implementation ********************************/
10937 /** @brief Copy Errors Test constructor.
10939 * @param [in] context OpenGL context.
10941 CopyErrorsTest::CopyErrorsTest(deqp::Context& context)
10942 : deqp::TestCase(context, "textures_copy_errors", "Texture Copy Errors Test")
10945 , m_fbo_incomplete(0)
10953 /* Intentionally left blank. */
10956 /** @brief Iterate Copy Errors Test cases.
10958 * @return Iteration result.
10960 tcu::TestNode::IterateResult CopyErrorsTest::iterate()
10962 /* Get context setup. */
10963 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
10964 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
10966 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
10968 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
10973 /* Running tests. */
10975 bool is_error = false;
10994 /* Result's setup. */
10997 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
11003 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
11007 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
11014 /** @brief Prepare test's objects and values.
11016 void CopyErrorsTest::Prepare()
11018 /* Shortcut for GL functionality. */
11019 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
11021 /* Auxiliary objects setup. */
11024 gl.genFramebuffers(1, &m_fbo);
11025 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
11027 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
11028 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11030 gl.createTextures(GL_TEXTURE_2D, 1, &m_to_src);
11031 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
11033 gl.textureStorage2D(m_to_src, 1, s_internalformat, s_width, s_height);
11034 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage2D has failed");
11036 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_to_src, 0);
11037 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferTexture1D call failed.");
11039 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
11044 gl.viewport(0, 0, s_width, s_height);
11045 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
11047 gl.clear(GL_COLOR_BUFFER_BIT);
11048 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear call failed.");
11050 /* Framebuffer Multisample. */
11051 gl.genFramebuffers(1, &m_fbo_ms);
11052 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
11054 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_ms);
11055 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11057 gl.createTextures(GL_TEXTURE_2D_MULTISAMPLE, 1, &m_to_src_ms);
11058 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
11060 gl.textureStorage2DMultisample(m_to_src_ms, 1, s_internalformat, s_width, s_height, false);
11061 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage2DMultisample has failed");
11063 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, m_to_src_ms, 0);
11064 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferTexture1D call failed.");
11066 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
11071 gl.viewport(0, 0, s_width, s_height);
11072 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
11074 gl.clear(GL_COLOR_BUFFER_BIT);
11075 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear call failed.");
11077 /* Framebuffer Incomplete. */
11078 gl.createFramebuffers(1, &m_fbo_incomplete);
11079 GLU_EXPECT_NO_ERROR(gl.getError(), "glcreateFramebuffers call failed.");
11082 gl.createTextures(GL_TEXTURE_1D, 1, &m_to_1D_dst);
11083 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
11085 gl.textureStorage1D(m_to_1D_dst, 1, s_internalformat, s_width);
11086 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage2D has failed");
11089 gl.createTextures(GL_TEXTURE_2D, 1, &m_to_2D_dst);
11090 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
11092 gl.textureStorage2D(m_to_2D_dst, 1, s_internalformat, s_width, s_height);
11093 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage2D has failed");
11096 gl.createTextures(GL_TEXTURE_3D, 1, &m_to_3D_dst);
11097 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
11099 gl.textureStorage3D(m_to_3D_dst, 1, s_internalformat, s_width, s_height, s_depth);
11100 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage2D has failed");
11102 /* invalid texture object */
11103 while (gl.isTexture(++m_to_invalid))
11105 GLU_EXPECT_NO_ERROR(gl.getError(), "glIsTexture has failed");
11108 /** @brief Test (negative) of CopyTextureSubImage1D
11110 * @return Test result.
11112 bool CopyErrorsTest::Test1D()
11114 /* Shortcut for GL functionality. */
11115 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
11120 /* Bind framebuffer. */
11121 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_incomplete);
11122 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11124 /* Check that INVALID_FRAMEBUFFER_OPERATION is generated by
11125 CopyTextureSubImage1D if the object bound to READ_FRAMEBUFFER_BINDING is
11126 not framebuffer complete. */
11128 gl.copyTextureSubImage1D(m_to_1D_dst, 0, 0, 0, 0, s_width);
11129 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_FRAMEBUFFER_OPERATION, "glCopyTextureSubImage1D",
11130 "the object bound to READ_FRAMEBUFFER_BINDING is not framebuffer complete.");
11133 /* Bind framebuffer. */
11134 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
11135 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11137 gl.readBuffer(GL_COLOR_ATTACHMENT0);
11138 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11140 /* Check that INVALID_OPERATION is generated by CopyTextureSubImage1D if
11141 texture is not the name of an existing texture object, or if the
11142 effective target of texture is not TEXTURE_1D. */
11144 gl.copyTextureSubImage1D(m_to_invalid, 0, 0, 0, 0, s_width);
11145 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage1D",
11146 "texture is not the name of an existing texture object.");
11148 gl.copyTextureSubImage1D(m_to_2D_dst, 0, 0, 0, 0, s_width);
11149 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage1D",
11150 "the effective target of texture is not TEXTURE_1D.");
11153 /* Check that INVALID_VALUE is generated by CopyTextureSubImage1D if level is less than 0. */
11155 gl.copyTextureSubImage1D(m_to_1D_dst, -1, 0, 0, 0, s_width);
11156 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage1D", "level is less than 0.");
11159 /* Check that INVALID_VALUE is generated by CopyTextureSubImage1D if
11160 xoffset<0, or (xoffset+width)>w, where w is the TEXTURE_WIDTH of the
11161 texture image being modified. */
11163 gl.copyTextureSubImage1D(m_to_1D_dst, 0, -1, 0, 0, s_width);
11164 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage1D", "xoffset<0.");
11166 gl.copyTextureSubImage1D(m_to_1D_dst, 0, 1, 0, 0, s_width);
11168 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage1D",
11169 "(xoffset+width)>w, where w is the TEXTURE_WIDTH of the texture image being modified.");
11172 /* Check that INVALID_OPERATION is generated by CopyTextureSubImage1D if
11173 the read buffer is NONE. */
11174 gl.readBuffer(GL_NONE);
11175 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11178 gl.copyTextureSubImage1D(m_to_1D_dst, 0, 0, 0, 0, s_width);
11180 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage1D", "the read buffer is NONE.");
11183 /* Bind multisample framebuffer. */
11184 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_ms);
11185 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11187 gl.readBuffer(GL_COLOR_ATTACHMENT0);
11188 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11190 /* Check that INVALID_OPERATION is generated by CopyTextureSubImage1D if
11191 the effective value of SAMPLE_BUFFERS for the read
11192 framebuffer is one. */
11194 gl.copyTextureSubImage1D(m_to_1D_dst, 0, 0, 0, 0, s_width);
11195 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage1D",
11196 "the effective value of SAMPLE_BUFFERS for the read framebuffer is one.");
11202 /** @brief Test (negative) of CopyTextureSubImage2D
11204 * @return Test result.
11206 bool CopyErrorsTest::Test2D()
11208 /* Shortcut for GL functionality. */
11209 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
11214 /* Bind framebuffer. */
11215 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_incomplete);
11216 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11218 /* Check that INVALID_FRAMEBUFFER_OPERATION is generated by
11219 CopyTextureSubImage2D if the object bound to READ_FRAMEBUFFER_BINDING is
11220 not framebuffer complete. */
11222 gl.copyTextureSubImage2D(m_to_2D_dst, 0, 0, 0, 0, 0, s_width, s_height);
11223 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_FRAMEBUFFER_OPERATION, "glCopyTextureSubImage2D",
11224 "the object bound to READ_FRAMEBUFFER_BINDING is not framebuffer complete.");
11227 /* Bind framebuffer. */
11228 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
11229 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11231 gl.readBuffer(GL_COLOR_ATTACHMENT0);
11232 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11234 /* Check that INVALID_OPERATION is generated by CopyTextureSubImage2D if
11235 texture is not the name of an existing texture object, or if the
11236 effective target of texture is not TEXTURE_2D. */
11238 gl.copyTextureSubImage2D(m_to_invalid, 0, 0, 0, 0, 0, s_width, s_height);
11239 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage2D",
11240 "texture is not the name of an existing texture object.");
11242 gl.copyTextureSubImage2D(m_to_1D_dst, 0, 0, 0, 0, 0, s_width, s_height);
11243 is_ok &= CheckErrorAndLog(
11244 m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage2D",
11245 "the effective target of does not correspond to one of the texture targets supported by the function..");
11248 /* Check that INVALID_VALUE is generated by CopyTextureSubImage2D if level is less than 0. */
11250 gl.copyTextureSubImage2D(m_to_2D_dst, -1, 0, 0, 0, 0, s_width, s_height);
11251 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage2D", "level is less than 0.");
11254 /* Check that INVALID_VALUE is generated by CopyTextureSubImage2D if
11255 xoffset<0, (xoffset+width)>w, yoffset<0, or (yoffset+height)>0, where w
11256 is the TEXTURE_WIDTH, h is the TEXTURE_HEIGHT and of the texture image
11259 gl.copyTextureSubImage2D(m_to_2D_dst, 0, -1, 0, 0, 0, s_width, s_height);
11260 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage2D", "xoffset<0.");
11262 gl.copyTextureSubImage2D(m_to_2D_dst, 0, 1, 0, 0, 0, s_width, s_height);
11264 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage2D",
11265 "(xoffset+width)>w, where w is the TEXTURE_WIDTH of the texture image being modified.");
11267 gl.copyTextureSubImage2D(m_to_2D_dst, 0, 0, -1, 0, 0, s_width, s_height);
11268 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage2D", "yoffset<0.");
11270 gl.copyTextureSubImage2D(m_to_2D_dst, 0, 0, 1, 0, 0, s_width, s_height);
11272 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage2D",
11273 "(yoffset+height)>h, where h is the TEXTURE_HEIGHT of the texture image being modified.");
11276 /* Check that INVALID_OPERATION is generated by CopyTextureSubImage2D if
11277 the read buffer is NONE. */
11278 gl.readBuffer(GL_NONE);
11279 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11282 gl.copyTextureSubImage2D(m_to_2D_dst, 0, 0, 0, 0, 0, s_width, s_height);
11284 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage2D", "the read buffer is NONE.");
11287 /* Bind multisample framebuffer. */
11288 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_ms);
11289 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11291 gl.readBuffer(GL_COLOR_ATTACHMENT0);
11292 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11294 /* Check that INVALID_OPERATION is generated by CopyTextureSubImage2D if
11295 the effective value of SAMPLE_BUFFERS for the read
11296 framebuffer is one. */
11298 gl.copyTextureSubImage2D(m_to_2D_dst, 0, 0, 0, 0, 0, s_width, s_height);
11299 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage2D",
11300 "the effective value of SAMPLE_BUFFERS for the read framebuffer is one.");
11306 /** @brief Test (negative) of CopyTextureSubImage3D
11308 * @return Test result.
11310 bool CopyErrorsTest::Test3D()
11312 /* Shortcut for GL functionality. */
11313 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
11318 /* Bind framebuffer. */
11319 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_incomplete);
11320 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11322 /* Check that INVALID_FRAMEBUFFER_OPERATION is generated by
11323 CopyTextureSubImage3D if the object bound to READ_FRAMEBUFFER_BINDING is
11324 not framebuffer complete. */
11326 gl.copyTextureSubImage3D(m_to_3D_dst, 0, 0, 0, 0, 0, 0, s_width, s_height);
11327 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_FRAMEBUFFER_OPERATION, "glCopyTextureSubImage3D",
11328 "the object bound to READ_FRAMEBUFFER_BINDING is not framebuffer complete.");
11331 /* Bind framebuffer. */
11332 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
11333 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11335 gl.readBuffer(GL_COLOR_ATTACHMENT0);
11336 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11338 /* Check that INVALID_OPERATION is generated by CopyTextureSubImage3D if
11339 texture is not the name of an existing texture object, or if the
11340 effective target of texture is not supported by the function. */
11342 gl.copyTextureSubImage3D(m_to_invalid, 0, 0, 0, 0, 0, 0, s_width, s_height);
11343 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage3D",
11344 "texture is not the name of an existing texture object.");
11346 gl.copyTextureSubImage3D(m_to_1D_dst, 0, 0, 0, 0, 0, 0, s_width, s_height);
11347 is_ok &= CheckErrorAndLog(
11348 m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage3D",
11349 "the effective target of does not correspond to one of the texture targets supported by the function..");
11352 /* Check that INVALID_VALUE is generated by CopyTextureSubImage3D if level is less than 0. */
11354 gl.copyTextureSubImage3D(m_to_3D_dst, -1, 0, 0, 0, 0, 0, s_width, s_height);
11355 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage3D", "level is less than 0.");
11358 /* Check that INVALID_VALUE is generated by CopyTextureSubImage3D if
11359 xoffset<0, (xoffset+width)>w, yoffset<0, (yoffset+height)>h, zoffset<0,
11360 or (zoffset+1)>d, where w is the TEXTURE_WIDTH, h is the TEXTURE_HEIGHT,
11361 d is the TEXTURE_DEPTH and of the texture image being modified. Note
11362 that w, h, and d include twice the border width. */
11364 gl.copyTextureSubImage3D(m_to_3D_dst, 0, -1, 0, 0, 0, 0, s_width, s_height);
11365 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage3D", "xoffset<0.");
11367 gl.copyTextureSubImage3D(m_to_3D_dst, 0, 1, 0, 0, 0, 0, s_width, s_height);
11369 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage3D",
11370 "(xoffset+width)>w, where w is the TEXTURE_WIDTH of the texture image being modified.");
11372 gl.copyTextureSubImage3D(m_to_3D_dst, 0, 0, -1, 0, 0, 0, s_width, s_height);
11373 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage3D", "yoffset<0.");
11375 gl.copyTextureSubImage3D(m_to_3D_dst, 0, 0, 1, 0, 0, 0, s_width, s_height);
11377 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage3D",
11378 "(yoffset+height)>h, where h is the TEXTURE_HEIGHT of the texture image being modified.");
11380 gl.copyTextureSubImage3D(m_to_3D_dst, 0, 0, 0, -1, 0, 0, s_width, s_height);
11381 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage3D", "zoffset<0.");
11383 gl.copyTextureSubImage3D(m_to_3D_dst, 0, 0, 0, s_depth + 1, 0, 0, s_width, s_height);
11384 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage3D",
11385 "(zoffset+1)>d, where d is the TEXTURE_DEPTH of the texture image being modified.");
11388 /* Check that INVALID_OPERATION is generated by CopyTextureSubImage3D if
11389 the read buffer is NONE. */
11390 gl.readBuffer(GL_NONE);
11391 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11394 gl.copyTextureSubImage3D(m_to_3D_dst, 0, 0, 0, 0, 0, 0, s_width, s_height);
11396 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage3D", "the read buffer is NONE.");
11399 /* Bind multisample framebuffer. */
11400 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_ms);
11401 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11403 gl.readBuffer(GL_COLOR_ATTACHMENT0);
11404 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11406 /* Check that INVALID_OPERATION is generated by CopyTextureSubImage3D if
11407 the effective value of SAMPLE_BUFFERS for the read
11408 framebuffer is one. */
11410 gl.copyTextureSubImage3D(m_to_3D_dst, 0, 0, 0, 0, 0, 0, s_width, s_height);
11411 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage3D",
11412 "the effective value of SAMPLE_BUFFERS for the read framebuffer is one.");
11418 /** @brief Clean GL objects, test variables and GL errors.
11420 void CopyErrorsTest::Clean()
11422 /* Shortcut for GL functionality. */
11423 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
11428 gl.deleteFramebuffers(1, &m_fbo);
11435 gl.deleteFramebuffers(1, &m_fbo_ms);
11440 if (m_fbo_incomplete)
11442 gl.deleteFramebuffers(1, &m_fbo_incomplete);
11444 m_fbo_incomplete = 0;
11449 gl.deleteTextures(1, &m_to_src);
11456 gl.deleteTextures(1, &m_to_src_ms);
11463 gl.deleteTextures(1, &m_to_1D_dst);
11470 gl.deleteTextures(1, &m_to_2D_dst);
11477 gl.deleteTextures(1, &m_to_3D_dst);
11484 while (GL_NO_ERROR != gl.getError())
11488 /* Test's parameters. */
11489 const glw::GLuint CopyErrorsTest::s_width = 4;
11490 const glw::GLuint CopyErrorsTest::s_height = 4;
11491 const glw::GLuint CopyErrorsTest::s_depth = 4;
11492 const glw::GLuint CopyErrorsTest::s_internalformat = GL_RGBA8;
11494 /******************************** Parameter Setup Errors Test Implementation ********************************/
11496 /** @brief Parameter Setup Errors Test constructor.
11498 * @param [in] context OpenGL context.
11500 ParameterSetupErrorsTest::ParameterSetupErrorsTest(deqp::Context& context)
11501 : deqp::TestCase(context, "textures_parameter_setup_errors", "Texture Parameter Setup Errors Test")
11504 , m_to_rectangle(0)
11506 , m_pname_invalid(0)
11507 , m_depth_stencil_mode_invalid(0)
11509 /* Intentionally left blank. */
11512 /** @brief Iterate Parameter Setup Errors Test cases.
11514 * @return Iteration result.
11516 tcu::TestNode::IterateResult ParameterSetupErrorsTest::iterate()
11518 /* Get context setup. */
11519 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
11520 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
11522 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
11524 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
11529 /* Running tests. */
11531 bool is_error = false;
11541 is_ok &= TestIiv();
11542 is_ok &= TestIuiv();
11553 /* Result's setup. */
11556 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
11562 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
11566 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
11573 /** @brief Test's preparations.
11575 void ParameterSetupErrorsTest::Prepare()
11577 /* Shortcut for GL functionality. */
11578 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
11580 /* Auxiliary objects setup. */
11583 gl.createTextures(GL_TEXTURE_2D, 1, &m_to_2D);
11584 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
11587 gl.createTextures(GL_TEXTURE_2D_MULTISAMPLE, 1, &m_to_2D_ms);
11588 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
11591 gl.createTextures(GL_TEXTURE_RECTANGLE, 1, &m_to_rectangle);
11592 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
11594 /* Invalid texture object. */
11595 while (gl.isTexture(++m_to_invalid))
11597 GLU_EXPECT_NO_ERROR(gl.getError(), "glIsTexture has failed");
11599 /* Invalid parameter name. */
11600 glw::GLenum all_pnames[] = { GL_DEPTH_STENCIL_TEXTURE_MODE,
11601 GL_TEXTURE_BASE_LEVEL,
11602 GL_TEXTURE_COMPARE_FUNC,
11603 GL_TEXTURE_COMPARE_MODE,
11604 GL_TEXTURE_LOD_BIAS,
11605 GL_TEXTURE_MIN_FILTER,
11606 GL_TEXTURE_MAG_FILTER,
11607 GL_TEXTURE_MIN_LOD,
11608 GL_TEXTURE_MAX_LOD,
11609 GL_TEXTURE_MAX_LEVEL,
11610 GL_TEXTURE_SWIZZLE_R,
11611 GL_TEXTURE_SWIZZLE_G,
11612 GL_TEXTURE_SWIZZLE_B,
11613 GL_TEXTURE_SWIZZLE_A,
11617 GL_TEXTURE_BORDER_COLOR,
11618 GL_TEXTURE_SWIZZLE_RGBA };
11619 glw::GLuint all_pnames_count = sizeof(all_pnames) / sizeof(all_pnames[0]);
11621 bool is_valid = true;
11628 for (glw::GLuint i = 0; i < all_pnames_count; ++i)
11630 if (all_pnames[i] == m_pname_invalid)
11639 /* Invalid depth stencil mode name. */
11640 glw::GLenum all_depth_stencil_modes[] = { GL_DEPTH_COMPONENT, GL_STENCIL_INDEX };
11641 glw::GLuint all_depth_stencil_modes_count = sizeof(all_depth_stencil_modes) / sizeof(all_depth_stencil_modes[0]);
11648 ++m_depth_stencil_mode_invalid;
11650 for (glw::GLuint i = 0; i < all_depth_stencil_modes_count; ++i)
11652 if (all_depth_stencil_modes[i] == m_depth_stencil_mode_invalid)
11662 /** @brief Test (negative) of TextureParameterf
11664 * @return Test result.
11666 bool ParameterSetupErrorsTest::Testf()
11668 /* Shortcut for GL functionality. */
11669 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
11674 /* Check that INVALID_ENUM is generated by TextureParameter* if pname is
11675 not one of the accepted defined values. */
11677 gl.textureParameterf(m_to_2D, m_pname_invalid, 1.f);
11679 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterf",
11680 "pname is not one of the accepted defined values.");
11683 /* Check that INVALID_ENUM is generated by TextureParameter* if params
11684 should have a defined constant value (based on the value of pname) and
11687 gl.textureParameterf(m_to_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, (glw::GLfloat)m_depth_stencil_mode_invalid);
11690 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterf",
11691 "params should have a defined constant value (based on the value of pname) and does not.");
11693 /* Check that INVALID_ENUM is generated if TextureParameter{if} is called
11694 for a non-scalar parameter (pname TEXTURE_BORDER_COLOR or
11695 TEXTURE_SWIZZLE_RGBA). */
11697 gl.textureParameterf(m_to_2D, GL_TEXTURE_BORDER_COLOR, 1.f);
11700 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterf",
11701 "called for a non-scalar parameter (pname TEXTURE_BORDER_COLOR or TEXTURE_SWIZZLE_RGBA).");
11704 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11705 effective target is either TEXTURE_2D_MULTISAMPLE or
11706 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states. */
11708 gl.textureParameterf(m_to_2D_ms, GL_TEXTURE_LOD_BIAS, 1.f);
11710 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterf",
11711 "the effective target is either TEXTURE_2D_MULTISAMPLE or "
11712 "TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states.");
11715 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11716 effective target is TEXTURE_RECTANGLE and either of pnames
11717 TEXTURE_WRAP_S or TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE,
11718 MIRRORED_REPEAT or REPEAT. */
11720 gl.textureParameterf(m_to_rectangle, GL_TEXTURE_WRAP_S, GL_MIRROR_CLAMP_TO_EDGE);
11722 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterf",
11723 "the effective target is TEXTURE_RECTANGLE and either of pnames TEXTURE_WRAP_S or "
11724 "TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE, MIRRORED_REPEAT or REPEAT.");
11727 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11728 effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is
11729 set to a value other than NEAREST or LINEAR (no mipmap filtering is
11732 gl.textureParameterf(m_to_rectangle, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
11734 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterf",
11735 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is set to a "
11736 "value other than NEAREST or LINEAR (no mipmap filtering is permitted).");
11739 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
11740 effective target is either TEXTURE_2D_MULTISAMPLE or
11741 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname TEXTURE_BASE_LEVEL is set to a
11742 value other than zero. */
11744 gl.textureParameterf(m_to_2D_ms, GL_TEXTURE_BASE_LEVEL, 1.f);
11747 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterf",
11748 "the effective target is either TEXTURE_2D_MULTISAMPLE or TEXTURE_2D_MULTISAMPLE_ARRAY, "
11749 "and pname TEXTURE_BASE_LEVEL is set to a value other than zero.");
11752 /* Check that INVALID_OPERATION is generated by TextureParameter* if
11753 texture is not the name of an existing texture object. */
11755 gl.textureParameterf(m_to_invalid, GL_TEXTURE_LOD_BIAS, 1.f);
11757 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterf",
11758 "texture is not the name of an existing texture object.");
11761 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
11762 effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is
11763 set to any value other than zero. */
11765 gl.textureParameterf(m_to_rectangle, GL_TEXTURE_BASE_LEVEL, 1.f);
11767 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterf",
11768 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is set to "
11769 "any value other than zero. ");
11772 /* Check that INVALID_VALUE is generated by TextureParameter* if pname is
11773 TEXTURE_BASE_LEVEL or TEXTURE_MAX_LEVEL, and param or params is
11776 gl.textureParameterf(m_to_2D, GL_TEXTURE_BASE_LEVEL, -1.f);
11778 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureParameterf",
11779 "pname is TEXTURE_BASE_LEVEL and param is negative.");
11781 gl.textureParameterf(m_to_2D, GL_TEXTURE_MAX_LEVEL, -1.f);
11783 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureParameterf",
11784 "pname is TEXTURE_MAX_LEVEL and param is negative.");
11790 /** @brief Test (negative) of TextureParameteri
11792 * @return Test result.
11794 bool ParameterSetupErrorsTest::Testi()
11796 /* Shortcut for GL functionality. */
11797 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
11802 /* Check that INVALID_ENUM is generated by TextureParameter* if pname is
11803 not one of the accepted defined values. */
11805 gl.textureParameteri(m_to_2D, m_pname_invalid, 1);
11807 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteri",
11808 "pname is not one of the accepted defined values.");
11811 /* Check that INVALID_ENUM is generated by TextureParameter* if params
11812 should have a defined constant value (based on the value of pname) and
11815 gl.textureParameteri(m_to_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, m_depth_stencil_mode_invalid);
11818 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteri",
11819 "params should have a defined constant value (based on the value of pname) and does not.");
11821 /* Check that INVALID_ENUM is generated if TextureParameter{if} is called
11822 for a non-scalar parameter (pname TEXTURE_BORDER_COLOR or
11823 TEXTURE_SWIZZLE_RGBA). */
11825 gl.textureParameteri(m_to_2D, GL_TEXTURE_BORDER_COLOR, 1);
11828 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteri",
11829 "called for a non-scalar parameter (pname TEXTURE_BORDER_COLOR or TEXTURE_SWIZZLE_RGBA).");
11832 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11833 effective target is either TEXTURE_2D_MULTISAMPLE or
11834 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states. */
11836 gl.textureParameteri(m_to_2D_ms, GL_TEXTURE_LOD_BIAS, 1);
11838 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteri",
11839 "the effective target is either TEXTURE_2D_MULTISAMPLE or "
11840 "TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states.");
11843 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11844 effective target is TEXTURE_RECTANGLE and either of pnames
11845 TEXTURE_WRAP_S or TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE,
11846 MIRRORED_REPEAT or REPEAT. */
11848 gl.textureParameteri(m_to_rectangle, GL_TEXTURE_WRAP_S, GL_MIRROR_CLAMP_TO_EDGE);
11850 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteri",
11851 "the effective target is TEXTURE_RECTANGLE and either of pnames TEXTURE_WRAP_S or "
11852 "TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE, MIRRORED_REPEAT or REPEAT.");
11855 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11856 effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is
11857 set to a value other than NEAREST or LINEAR (no mipmap filtering is
11860 gl.textureParameteri(m_to_rectangle, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
11862 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteri",
11863 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is set to a "
11864 "value other than NEAREST or LINEAR (no mipmap filtering is permitted).");
11867 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
11868 effective target is either TEXTURE_2D_MULTISAMPLE or
11869 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname TEXTURE_BASE_LEVEL is set to a
11870 value other than zero. */
11872 gl.textureParameteri(m_to_2D_ms, GL_TEXTURE_BASE_LEVEL, 1);
11875 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameteri",
11876 "the effective target is either TEXTURE_2D_MULTISAMPLE or TEXTURE_2D_MULTISAMPLE_ARRAY, "
11877 "and pname TEXTURE_BASE_LEVEL is set to a value other than zero.");
11880 /* Check that INVALID_OPERATION is generated by TextureParameter* if
11881 texture is not the name of an existing texture object. */
11883 gl.textureParameteri(m_to_invalid, GL_TEXTURE_LOD_BIAS, 1);
11885 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameteri",
11886 "texture is not the name of an existing texture object.");
11889 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
11890 effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is
11891 set to any value other than zero. */
11893 gl.textureParameteri(m_to_rectangle, GL_TEXTURE_BASE_LEVEL, 1);
11895 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameteri",
11896 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is set to "
11897 "any value other than zero. ");
11900 /* Check that INVALID_VALUE is generated by TextureParameter* if pname is
11901 TEXTURE_BASE_LEVEL or TEXTURE_MAX_LEVEL, and param or params is
11904 gl.textureParameteri(m_to_2D, GL_TEXTURE_BASE_LEVEL, -1);
11906 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureParameteri",
11907 "pname is TEXTURE_BASE_LEVEL and param is negative.");
11909 gl.textureParameteri(m_to_2D, GL_TEXTURE_MAX_LEVEL, -1);
11911 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureParameteri",
11912 "pname is TEXTURE_MAX_LEVEL and param is negative.");
11918 /** @brief Test (negative) of TextureParameterfv
11920 * @return Test result.
11922 bool ParameterSetupErrorsTest::Testfv()
11924 /* Shortcut for GL functionality. */
11925 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
11930 glw::GLfloat one = 1.f;
11931 glw::GLfloat minus_one = -1.f;
11932 glw::GLfloat depth_stencil_mode_invalid = (glw::GLfloat)m_depth_stencil_mode_invalid;
11933 glw::GLfloat wrap_invalid = (glw::GLfloat)GL_MIRROR_CLAMP_TO_EDGE;
11934 glw::GLfloat min_filter_invalid = (glw::GLfloat)GL_NEAREST_MIPMAP_NEAREST;
11936 /* Check that INVALID_ENUM is generated by TextureParameter* if pname is
11937 not one of the accepted defined values. */
11939 gl.textureParameterfv(m_to_2D, m_pname_invalid, &one);
11941 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterfv",
11942 "pname is not one of the accepted defined values.");
11945 /* Check that INVALID_ENUM is generated by TextureParameter* if params
11946 should have a defined constant value (based on the value of pname) and
11949 gl.textureParameterfv(m_to_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, &depth_stencil_mode_invalid);
11952 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterfv",
11953 "params should have a defined constant value (based on the value of pname) and does not.");
11956 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11957 effective target is either TEXTURE_2D_MULTISAMPLE or
11958 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states. */
11960 gl.textureParameterfv(m_to_2D_ms, GL_TEXTURE_LOD_BIAS, &one);
11962 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterfv",
11963 "the effective target is either TEXTURE_2D_MULTISAMPLE or "
11964 "TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states.");
11967 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11968 effective target is TEXTURE_RECTANGLE and either of pnames
11969 TEXTURE_WRAP_S or TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE,
11970 MIRRORED_REPEAT or REPEAT. */
11972 gl.textureParameterfv(m_to_rectangle, GL_TEXTURE_WRAP_S, &wrap_invalid);
11974 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterfv",
11975 "the effective target is TEXTURE_RECTANGLE and either of pnames TEXTURE_WRAP_S or "
11976 "TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE, MIRRORED_REPEAT or REPEAT.");
11979 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11980 effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is
11981 set to a value other than NEAREST or LINEAR (no mipmap filtering is
11984 gl.textureParameterfv(m_to_rectangle, GL_TEXTURE_MIN_FILTER, &min_filter_invalid);
11986 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterfv",
11987 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is set to a "
11988 "value other than NEAREST or LINEAR (no mipmap filtering is permitted).");
11991 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
11992 effective target is either TEXTURE_2D_MULTISAMPLE or
11993 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname TEXTURE_BASE_LEVEL is set to a
11994 value other than zero. */
11996 gl.textureParameterfv(m_to_2D_ms, GL_TEXTURE_BASE_LEVEL, &one);
11999 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterfv",
12000 "the effective target is either TEXTURE_2D_MULTISAMPLE or TEXTURE_2D_MULTISAMPLE_ARRAY, "
12001 "and pname TEXTURE_BASE_LEVEL is set to a value other than zero.");
12004 /* Check that INVALID_OPERATION is generated by TextureParameter* if
12005 texture is not the name of an existing texture object. */
12007 gl.textureParameterfv(m_to_invalid, GL_TEXTURE_LOD_BIAS, &one);
12009 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterfv",
12010 "texture is not the name of an existing texture object.");
12013 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
12014 effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is
12015 set to any value other than zero. */
12017 gl.textureParameterfv(m_to_rectangle, GL_TEXTURE_BASE_LEVEL, &one);
12019 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterfv",
12020 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is set to "
12021 "any value other than zero. ");
12024 /* Check that INVALID_VALUE is generated by TextureParameter* if pname is
12025 TEXTURE_BASE_LEVEL or TEXTURE_MAX_LEVEL, and param or params is
12028 gl.textureParameterfv(m_to_2D, GL_TEXTURE_BASE_LEVEL, &minus_one);
12030 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureParameterfv",
12031 "pname is TEXTURE_BASE_LEVEL and param is negative.");
12033 gl.textureParameterfv(m_to_2D, GL_TEXTURE_MAX_LEVEL, &minus_one);
12035 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureParameterfv",
12036 "pname is TEXTURE_MAX_LEVEL and param is negative.");
12042 /** @brief Test (negative) of TextureParameteriv
12044 * @return Test result.
12046 bool ParameterSetupErrorsTest::Testiv()
12048 /* Shortcut for GL functionality. */
12049 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
12054 glw::GLint one = 1;
12055 glw::GLint minus_one = -1;
12056 glw::GLint depth_stencil_mode_invalid = (glw::GLint)m_depth_stencil_mode_invalid;
12057 glw::GLint wrap_invalid = (glw::GLint)GL_MIRROR_CLAMP_TO_EDGE;
12058 glw::GLint min_filter_invalid = (glw::GLint)GL_NEAREST_MIPMAP_NEAREST;
12060 /* Check that INVALID_ENUM is generated by TextureParameter* if pname is
12061 not one of the accepted defined values. */
12063 gl.textureParameteriv(m_to_2D, m_pname_invalid, &one);
12065 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteriv",
12066 "pname is not one of the accepted defined values.");
12069 /* Check that INVALID_ENUM is generated by TextureParameter* if params
12070 should have a defined constant value (based on the value of pname) and
12073 gl.textureParameteriv(m_to_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, &depth_stencil_mode_invalid);
12076 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteriv",
12077 "params should have a defined constant value (based on the value of pname) and does not.");
12080 /* Check that INVALID_ENUM is generated by TextureParameter* if the
12081 effective target is either TEXTURE_2D_MULTISAMPLE or
12082 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states. */
12084 gl.textureParameteriv(m_to_2D_ms, GL_TEXTURE_LOD_BIAS, &one);
12086 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteriv",
12087 "the effective target is either TEXTURE_2D_MULTISAMPLE or "
12088 "TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states.");
12091 /* Check that INVALID_ENUM is generated by TextureParameter* if the
12092 effective target is TEXTURE_RECTANGLE and either of pnames
12093 TEXTURE_WRAP_S or TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE,
12094 MIRRORED_REPEAT or REPEAT. */
12096 gl.textureParameteriv(m_to_rectangle, GL_TEXTURE_WRAP_S, &wrap_invalid);
12098 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteriv",
12099 "the effective target is TEXTURE_RECTANGLE and either of pnames TEXTURE_WRAP_S or "
12100 "TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE, MIRRORED_REPEAT or REPEAT.");
12103 /* Check that INVALID_ENUM is generated by TextureParameter* if the
12104 effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is
12105 set to a value other than NEAREST or LINEAR (no mipmap filtering is
12108 gl.textureParameteriv(m_to_rectangle, GL_TEXTURE_MIN_FILTER, &min_filter_invalid);
12110 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteriv",
12111 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is set to a "
12112 "value other than NEAREST or LINEAR (no mipmap filtering is permitted).");
12115 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
12116 effective target is either TEXTURE_2D_MULTISAMPLE or
12117 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname TEXTURE_BASE_LEVEL is set to a
12118 value other than zero. */
12120 gl.textureParameteriv(m_to_2D_ms, GL_TEXTURE_BASE_LEVEL, &one);
12123 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameteriv",
12124 "the effective target is either TEXTURE_2D_MULTISAMPLE or TEXTURE_2D_MULTISAMPLE_ARRAY, "
12125 "and pname TEXTURE_BASE_LEVEL is set to a value other than zero.");
12128 /* Check that INVALID_OPERATION is generated by TextureParameter* if
12129 texture is not the name of an existing texture object. */
12131 gl.textureParameteriv(m_to_invalid, GL_TEXTURE_LOD_BIAS, &one);
12133 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameteriv",
12134 "texture is not the name of an existing texture object.");
12137 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
12138 effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is
12139 set to any value other than zero. */
12141 gl.textureParameteriv(m_to_rectangle, GL_TEXTURE_BASE_LEVEL, &one);
12143 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameteriv",
12144 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is set to "
12145 "any value other than zero. ");
12148 /* Check that INVALID_VALUE is generated by TextureParameter* if pname is
12149 TEXTURE_BASE_LEVEL or TEXTURE_MAX_LEVEL, and param or params is
12152 gl.textureParameteriv(m_to_2D, GL_TEXTURE_BASE_LEVEL, &minus_one);
12154 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureParameteriv",
12155 "pname is TEXTURE_BASE_LEVEL and param is negative.");
12157 gl.textureParameteriv(m_to_2D, GL_TEXTURE_MAX_LEVEL, &minus_one);
12159 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureParameteriv",
12160 "pname is TEXTURE_MAX_LEVEL and param is negative.");
12166 /** @brief Test (negative) of TextureParameterIiv
12168 * @return Test result.
12170 bool ParameterSetupErrorsTest::TestIiv()
12172 /* Shortcut for GL functionality. */
12173 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
12178 glw::GLint one = 1;
12179 glw::GLint minus_one = -1;
12180 glw::GLint depth_stencil_mode_invalid = (glw::GLint)m_depth_stencil_mode_invalid;
12181 glw::GLint wrap_invalid = (glw::GLint)GL_MIRROR_CLAMP_TO_EDGE;
12182 glw::GLint min_filter_invalid = (glw::GLint)GL_NEAREST_MIPMAP_NEAREST;
12184 /* Check that INVALID_ENUM is generated by TextureParameter* if pname is
12185 not one of the accepted defined values. */
12187 gl.textureParameterIiv(m_to_2D, m_pname_invalid, &one);
12189 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterIiv",
12190 "pname is not one of the accepted defined values.");
12193 /* Check that INVALID_ENUM is generated by TextureParameter* if params
12194 should have a defined constant value (based on the value of pname) and
12197 gl.textureParameterIiv(m_to_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, &depth_stencil_mode_invalid);
12200 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterIiv",
12201 "params should have a defined constant value (based on the value of pname) and does not.");
12204 /* Check that INVALID_ENUM is generated by TextureParameter* if the
12205 effective target is either TEXTURE_2D_MULTISAMPLE or
12206 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states. */
12208 gl.textureParameterIiv(m_to_2D_ms, GL_TEXTURE_LOD_BIAS, &one);
12210 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterIiv",
12211 "the effective target is either TEXTURE_2D_MULTISAMPLE or "
12212 "TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states.");
12215 /* Check that INVALID_ENUM is generated by TextureParameter* if the
12216 effective target is TEXTURE_RECTANGLE and either of pnames
12217 TEXTURE_WRAP_S or TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE,
12218 MIRRORED_REPEAT or REPEAT. */
12220 gl.textureParameterIiv(m_to_rectangle, GL_TEXTURE_WRAP_S, &wrap_invalid);
12222 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterIiv",
12223 "the effective target is TEXTURE_RECTANGLE and either of pnames TEXTURE_WRAP_S or "
12224 "TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE, MIRRORED_REPEAT or REPEAT.");
12227 /* Check that INVALID_ENUM is generated by TextureParameter* if the
12228 effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is
12229 set to a value other than NEAREST or LINEAR (no mipmap filtering is
12232 gl.textureParameterIiv(m_to_rectangle, GL_TEXTURE_MIN_FILTER, &min_filter_invalid);
12234 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterIiv",
12235 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is set to a "
12236 "value other than NEAREST or LINEAR (no mipmap filtering is permitted).");
12239 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
12240 effective target is either TEXTURE_2D_MULTISAMPLE or
12241 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname TEXTURE_BASE_LEVEL is set to a
12242 value other than zero. */
12244 gl.textureParameterIiv(m_to_2D_ms, GL_TEXTURE_BASE_LEVEL, &one);
12247 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterIiv",
12248 "the effective target is either TEXTURE_2D_MULTISAMPLE or TEXTURE_2D_MULTISAMPLE_ARRAY, "
12249 "and pname TEXTURE_BASE_LEVEL is set to a value other than zero.");
12252 /* Check that INVALID_OPERATION is generated by TextureParameter* if
12253 texture is not the name of an existing texture object. */
12255 gl.textureParameterIiv(m_to_invalid, GL_TEXTURE_LOD_BIAS, &one);
12257 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterIiv",
12258 "texture is not the name of an existing texture object.");
12261 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
12262 effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is
12263 set to any value other than zero. */
12265 gl.textureParameterIiv(m_to_rectangle, GL_TEXTURE_BASE_LEVEL, &one);
12267 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterIiv",
12268 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is set to "
12269 "any value other than zero. ");
12272 /* Check that INVALID_VALUE is generated by TextureParameter* if pname is
12273 TEXTURE_BASE_LEVEL or TEXTURE_MAX_LEVEL, and param or params is
12276 gl.textureParameterIiv(m_to_2D, GL_TEXTURE_BASE_LEVEL, &minus_one);
12278 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureParameterIiv",
12279 "pname is TEXTURE_BASE_LEVEL and param is negative.");
12281 gl.textureParameterIiv(m_to_2D, GL_TEXTURE_MAX_LEVEL, &minus_one);
12283 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureParameterIiv",
12284 "pname is TEXTURE_MAX_LEVEL and param is negative.");
12290 /** @brief Test (negative) of TextureParameterIuiv
12292 * @return Test result.
12294 bool ParameterSetupErrorsTest::TestIuiv()
12296 /* Shortcut for GL functionality. */
12297 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
12302 glw::GLuint one = 1;
12303 glw::GLuint depth_stencil_mode_invalid = (glw::GLint)m_depth_stencil_mode_invalid;
12304 glw::GLuint wrap_invalid = (glw::GLint)GL_MIRROR_CLAMP_TO_EDGE;
12305 glw::GLuint min_filter_invalid = (glw::GLint)GL_NEAREST_MIPMAP_NEAREST;
12307 /* Check that INVALID_ENUM is generated by TextureParameter* if pname is
12308 not one of the accepted defined values. */
12310 gl.textureParameterIuiv(m_to_2D, m_pname_invalid, &one);
12312 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterIuiv",
12313 "pname is not one of the accepted defined values.");
12316 /* Check that INVALID_ENUM is generated by TextureParameter* if params
12317 should have a defined constant value (based on the value of pname) and
12320 gl.textureParameterIuiv(m_to_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, &depth_stencil_mode_invalid);
12323 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterIuiv",
12324 "params should have a defined constant value (based on the value of pname) and does not.");
12327 /* Check that INVALID_ENUM is generated by TextureParameter* if the
12328 effective target is either TEXTURE_2D_MULTISAMPLE or
12329 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states. */
12331 gl.textureParameterIuiv(m_to_2D_ms, GL_TEXTURE_LOD_BIAS, &one);
12333 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterIuiv",
12334 "the effective target is either TEXTURE_2D_MULTISAMPLE or "
12335 "TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states.");
12338 /* Check that INVALID_ENUM is generated by TextureParameter* if the
12339 effective target is TEXTURE_RECTANGLE and either of pnames
12340 TEXTURE_WRAP_S or TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE,
12341 MIRRORED_REPEAT or REPEAT. */
12343 gl.textureParameterIuiv(m_to_rectangle, GL_TEXTURE_WRAP_S, &wrap_invalid);
12345 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterIuiv",
12346 "the effective target is TEXTURE_RECTANGLE and either of pnames TEXTURE_WRAP_S or "
12347 "TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE, MIRRORED_REPEAT or REPEAT.");
12350 /* Check that INVALID_ENUM is generated by TextureParameter* if the
12351 effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is
12352 set to a value other than NEAREST or LINEAR (no mipmap filtering is
12355 gl.textureParameterIuiv(m_to_rectangle, GL_TEXTURE_MIN_FILTER, &min_filter_invalid);
12357 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterIuiv",
12358 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is set to a "
12359 "value other than NEAREST or LINEAR (no mipmap filtering is permitted).");
12362 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
12363 effective target is either TEXTURE_2D_MULTISAMPLE or
12364 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname TEXTURE_BASE_LEVEL is set to a
12365 value other than zero. */
12367 gl.textureParameterIuiv(m_to_2D_ms, GL_TEXTURE_BASE_LEVEL, &one);
12370 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterIuiv",
12371 "the effective target is either TEXTURE_2D_MULTISAMPLE or TEXTURE_2D_MULTISAMPLE_ARRAY, "
12372 "and pname TEXTURE_BASE_LEVEL is set to a value other than zero.");
12375 /* Check that INVALID_OPERATION is generated by TextureParameter* if
12376 texture is not the name of an existing texture object. */
12378 gl.textureParameterIuiv(m_to_invalid, GL_TEXTURE_LOD_BIAS, &one);
12380 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterIuiv",
12381 "texture is not the name of an existing texture object.");
12384 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
12385 effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is
12386 set to any value other than zero. */
12388 gl.textureParameterIuiv(m_to_rectangle, GL_TEXTURE_BASE_LEVEL, &one);
12390 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterIuiv",
12391 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is set to "
12392 "any value other than zero. ");
12398 /** @brief Clean GL objects, test variables and GL errors.
12400 void ParameterSetupErrorsTest::Clean()
12402 /* Shortcut for GL functionality. */
12403 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
12408 gl.deleteTextures(1, &m_to_2D);
12415 gl.deleteTextures(1, &m_to_2D_ms);
12420 if (m_to_rectangle)
12422 gl.deleteTextures(1, &m_to_rectangle);
12424 m_to_rectangle = 0;
12429 gl.deleteTextures(1, &m_to_invalid);
12435 m_pname_invalid = 0;
12437 while (GL_NO_ERROR != gl.getError())
12441 /******************************** Generate Mipmap Errors Test Implementation ********************************/
12443 /** @brief Generate Mipmap Errors Test constructor.
12445 * @param [in] context OpenGL context.
12447 GenerateMipmapErrorsTest::GenerateMipmapErrorsTest(deqp::Context& context)
12448 : deqp::TestCase(context, "textures_generate_mipmap_errors", "Texture Generate Mipmap Errors Test")
12450 /* Intentionally left blank. */
12453 /** @brief Iterate Generate Mipmap Errors Test cases.
12455 * @return Iteration result.
12457 tcu::TestNode::IterateResult GenerateMipmapErrorsTest::iterate()
12459 /* Shortcut for GL functionality. */
12460 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
12462 /* Get context setup. */
12463 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
12464 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
12466 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
12468 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
12473 /* Running tests. */
12475 bool is_error = false;
12478 glw::GLuint texture_invalid = 0;
12479 glw::GLuint texture_cube = 0;
12483 /* Preparations. */
12485 /* incomplete cube map */
12486 gl.genTextures(1, &texture_cube);
12487 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
12489 gl.bindTexture(GL_TEXTURE_CUBE_MAP, texture_cube);
12490 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
12492 gl.texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, s_reference_internalformat, s_reference_width,
12493 s_reference_height, 0, s_reference_format, s_reference_type, s_reference_data);
12494 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
12496 /* invalid texture */
12497 while (gl.isTexture(++texture_invalid))
12500 /* Check that INVALID_OPERATION is generated by GenerateTextureMipmap if
12501 texture is not the name of an existing texture object. */
12502 gl.generateTextureMipmap(texture_invalid);
12503 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGenerateTextureMipmap",
12504 "texture is not the name of an existing texture object.");
12506 /* Check that INVALID_OPERATION is generated by GenerateTextureMipmap if
12507 target is TEXTURE_CUBE_MAP or TEXTURE_CUBE_MAP_ARRAY, and the specified
12508 texture object is not cube complete or cube array complete,
12510 gl.generateTextureMipmap(texture_cube);
12511 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGenerateTextureMipmap",
12512 "target is TEXTURE_CUBE_MAP or TEXTURE_CUBE_MAP_ARRAY, and the specified texture "
12513 "object is not cube complete or cube array complete, respectively.");
12524 gl.deleteTextures(1, &texture_cube);
12527 while (GL_NO_ERROR != gl.getError())
12530 /* Result's setup. */
12533 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
12539 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
12543 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
12550 /** Reference data. */
12551 const glw::GLubyte GenerateMipmapErrorsTest::s_reference_data[] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
12552 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF };
12554 /** Reference data parameters. */
12555 const glw::GLuint GenerateMipmapErrorsTest::s_reference_width = 4;
12556 const glw::GLuint GenerateMipmapErrorsTest::s_reference_height = 4;
12557 const glw::GLenum GenerateMipmapErrorsTest::s_reference_internalformat = GL_R8;
12558 const glw::GLenum GenerateMipmapErrorsTest::s_reference_format = GL_RED;
12559 const glw::GLenum GenerateMipmapErrorsTest::s_reference_type = GL_UNSIGNED_BYTE;
12561 /******************************** Bind Unit Errors Test Implementation ********************************/
12563 /** @brief Bind Unit Errors Test constructor.
12565 * @param [in] context OpenGL context.
12567 BindUnitErrorsTest::BindUnitErrorsTest(deqp::Context& context)
12568 : deqp::TestCase(context, "textures_bind_unit_errors", "Texture Bind Unit Errors Test")
12570 /* Intentionally left blank. */
12573 /** @brief IterateBind Unit Errors Test cases.
12575 * @return Iteration result.
12577 tcu::TestNode::IterateResult BindUnitErrorsTest::iterate()
12579 /* Shortcut for GL functionality. */
12580 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
12582 /* Get context setup. */
12583 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
12584 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
12586 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
12588 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
12593 /* Running tests. */
12595 bool is_error = false;
12598 glw::GLuint texture_invalid = 0;
12602 /* Prepare invalid texture */
12603 while (gl.isTexture(++texture_invalid))
12606 /* incomplete cube map */
12608 /* Check that INVALID_OPERATION error is generated if texture is not zero
12609 or the name of an existing texture object. */
12610 gl.bindTextureUnit(0, texture_invalid);
12611 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glBindTextureUnit",
12612 "texture is not zero or the name of an existing texture object.");
12621 while (GL_NO_ERROR != gl.getError())
12624 /* Result's setup. */
12627 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
12633 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
12637 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
12644 /******************************** Image Query Errors Test Implementation ********************************/
12646 /** @brief Image Query Errors Test constructor.
12648 * @param [in] context OpenGL context.
12650 ImageQueryErrorsTest::ImageQueryErrorsTest(deqp::Context& context)
12651 : deqp::TestCase(context, "textures_image_query_errors", "Texture Image Query Errors Test")
12653 /* Intentionally left blank. */
12656 /** Reference data. */
12657 const glw::GLuint ImageQueryErrorsTest::s_reference_data[] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
12658 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF };
12660 /** Reference data parameters. */
12661 const glw::GLuint ImageQueryErrorsTest::s_reference_width = 4;
12662 const glw::GLuint ImageQueryErrorsTest::s_reference_height = 4;
12663 const glw::GLuint ImageQueryErrorsTest::s_reference_size = sizeof(s_reference_data);
12664 const glw::GLenum ImageQueryErrorsTest::s_reference_internalformat = GL_R8;
12665 const glw::GLenum ImageQueryErrorsTest::s_reference_internalformat_int = GL_R8I;
12666 const glw::GLenum ImageQueryErrorsTest::s_reference_internalformat_compressed = GL_COMPRESSED_RED_RGTC1;
12667 const glw::GLenum ImageQueryErrorsTest::s_reference_format = GL_RED;
12668 const glw::GLenum ImageQueryErrorsTest::s_reference_type = GL_UNSIGNED_INT;
12670 /** @brief Iterate Image Query Errors Test cases.
12672 * @return Iteration result.
12674 tcu::TestNode::IterateResult ImageQueryErrorsTest::iterate()
12676 /* Shortcut for GL functionality. */
12677 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
12679 /* Get context setup. */
12680 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
12681 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
12683 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
12685 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
12690 /* Running tests. */
12692 bool is_error = false;
12695 glw::GLuint buffer = 0;
12696 glw::GLuint texture_invalid = 0;
12697 glw::GLuint texture_2D = 0;
12698 glw::GLuint texture_2D_int = 0;
12699 glw::GLuint texture_2D_ms = 0;
12700 glw::GLuint texture_2D_stencil = 0;
12701 glw::GLuint texture_2D_compressed = 0;
12702 glw::GLuint texture_cube = 0;
12703 glw::GLuint texture_rectangle = 0;
12704 glw::GLint max_level = 0;
12705 char store[s_reference_size * 6 /* for cubemap */] = {};
12709 /* Preparations. */
12712 gl.createBuffers(1, &buffer);
12714 gl.namedBufferData(buffer, s_reference_size + 1, NULL, GL_STATIC_COPY);
12715 GLU_EXPECT_NO_ERROR(gl.getError(), "glNamedBufferData has failed");
12718 gl.genTextures(1, &texture_2D);
12719 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
12721 gl.bindTexture(GL_TEXTURE_2D, texture_2D);
12722 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
12724 gl.texImage2D(GL_TEXTURE_2D, 0, s_reference_internalformat, s_reference_width, s_reference_height, 0,
12725 s_reference_format, s_reference_type, s_reference_data);
12726 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
12729 gl.genTextures(1, &texture_2D);
12730 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
12732 gl.bindTexture(GL_TEXTURE_2D, texture_2D);
12733 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
12735 gl.texImage2D(GL_TEXTURE_2D, 0, s_reference_internalformat, s_reference_width, s_reference_height, 0,
12736 s_reference_format, s_reference_type, s_reference_data);
12737 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
12739 /* incomplete cube map */
12740 gl.genTextures(1, &texture_cube);
12741 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
12743 gl.bindTexture(GL_TEXTURE_CUBE_MAP, texture_cube);
12744 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
12746 gl.texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, s_reference_internalformat, s_reference_width,
12747 s_reference_height, 0, s_reference_format, s_reference_type, s_reference_data);
12748 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
12750 /* 2D multisample */
12751 gl.createTextures(GL_TEXTURE_2D_MULTISAMPLE, 1, &texture_2D_ms);
12752 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
12754 gl.textureStorage2DMultisample(texture_2D_ms, 1, s_reference_internalformat, s_reference_width,
12755 s_reference_height, false);
12756 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage2DMultisample has failed");
12759 gl.createTextures(GL_TEXTURE_2D, 1, &texture_2D_stencil);
12760 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
12762 gl.textureStorage2D(texture_2D_stencil, 1, GL_STENCIL_INDEX8, s_reference_width, s_reference_height);
12763 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage2DMultisample has failed");
12765 /* 2D compressed texture */
12766 gl.genTextures(1, &texture_2D_compressed);
12767 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
12769 gl.bindTexture(GL_TEXTURE_2D, texture_2D_compressed);
12770 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
12772 gl.texImage2D(GL_TEXTURE_2D, 0, s_reference_internalformat_compressed, s_reference_width, s_reference_height, 0,
12773 s_reference_format, s_reference_type, s_reference_data);
12774 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
12776 gl.getIntegerv(GL_MAX_TEXTURE_SIZE, &max_level); /* assuming that x > log(x) */
12777 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
12779 /* Rectangle texture */
12780 gl.genTextures(1, &texture_rectangle);
12781 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
12783 gl.bindTexture(GL_TEXTURE_RECTANGLE, texture_rectangle);
12784 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
12786 gl.texImage2D(GL_TEXTURE_RECTANGLE, 0, s_reference_internalformat, s_reference_width, s_reference_height, 0,
12787 s_reference_format, s_reference_type, s_reference_data);
12788 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
12790 /* invalid texture */
12791 while (gl.isTexture(++texture_invalid))
12796 /* Check that INVALID_ENUM is generated by GetTextureImage functions if
12797 resulting texture target is not an accepted value TEXTURE_1D,
12798 TEXTURE_2D, TEXTURE_3D, TEXTURE_1D_ARRAY, TEXTURE_2D_ARRAY,
12799 TEXTURE_CUBE_MAP_ARRAY, TEXTURE_RECTANGLE, and TEXTURE_CUBE_MAP. */
12800 gl.getTextureImage(texture_2D_ms, 0, s_reference_format, s_reference_type, s_reference_size, store);
12801 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glGetTextureImage",
12802 "resulting texture target is not an accepted value TEXTURE_1D, TEXTURE_2D, "
12803 "TEXTURE_3D, TEXTURE_1D_ARRAY, TEXTURE_2D_ARRAY, TEXTURE_CUBE_MAP_ARRAY, "
12804 "TEXTURE_RECTANGLE, and TEXTURE_CUBE_MAP.");
12806 /* Check that INVALID_OPERATION is generated by GetTextureImage
12807 if texture is not the name of an existing texture object. */
12808 gl.getTextureImage(texture_invalid, 0, s_reference_format, s_reference_type, s_reference_size, store);
12809 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12810 "texture is not the name of an existing texture object.");
12812 /* Check that INVALID_OPERATION error is generated by GetTextureImage if
12813 the effective target is TEXTURE_CUBE_MAP or TEXTURE_CUBE_MAP_ARRAY, and
12814 the texture object is not cube complete or cube array complete,
12816 gl.getTextureImage(texture_cube, 0, s_reference_format, s_reference_type, s_reference_size * 6, store);
12817 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12818 "the effective target is TEXTURE_CUBE_MAP and the texture object is not cube "
12819 "complete or cube array complete, respectively.");
12821 /* Check that GL_INVALID_VALUE is generated if level is less than 0 or
12822 larger than the maximum allowable level. */
12823 gl.getTextureImage(texture_2D, -1, s_reference_format, s_reference_type, s_reference_size, store);
12824 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glGetTextureImage", "level is less than 0.");
12826 gl.getTextureImage(texture_2D, max_level, s_reference_format, s_reference_type, s_reference_size, store);
12827 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glGetTextureImage",
12828 "level is larger than the maximum allowable level.");
12830 /* Check that INVALID_VALUE error is generated if level is non-zero and the
12831 effective target is TEXTURE_RECTANGLE. */
12832 gl.getTextureImage(texture_rectangle, 1, s_reference_format, s_reference_type, s_reference_size, store);
12833 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glGetTextureImage",
12834 "level is non-zero and the effective target is TEXTURE_RECTANGLE.");
12836 /* Check that INVALID_OPERATION error is generated if any of the following
12837 mismatches between format and the internal format of the texture image
12839 - format is a color format (one of the formats in table 8.3 whose
12840 target is the color buffer) and the base internal format of the
12841 texture image is not a color format.
12842 - format is DEPTH_COMPONENT and the base internal format is not
12843 DEPTH_COMPONENT or DEPTH_STENCIL
12844 - format is DEPTH_STENCIL and the base internal format is not
12846 - format is STENCIL_INDEX and the base internal format is not
12847 STENCIL_INDEX or DEPTH_STENCIL
12848 - format is one of the integer formats in table 8.3 and the internal
12849 format of the texture image is not integer, or format is not one of
12850 the integer formats in table 8.3 and the internal format is integer. */
12851 gl.getTextureImage(texture_2D_stencil, 0, s_reference_format /* red */, s_reference_type, s_reference_size,
12853 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12854 "format is a color format (one of the formats in table 8.3 whose target is the color "
12855 "buffer) and the base internal format of the texture image is not a color format.");
12857 gl.getTextureImage(texture_2D, 0, GL_DEPTH_COMPONENT, s_reference_type, s_reference_size, store);
12858 is_ok &= CheckErrorAndLog(
12859 m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12860 "format is DEPTH_COMPONENT and the base internal format is not DEPTH_COMPONENT or DEPTH_STENCIL.");
12862 gl.getTextureImage(texture_2D, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, s_reference_size, store);
12863 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12864 "format is DEPTH_STENCIL and the base internal format is not DEPTH_STENCIL.");
12866 gl.getTextureImage(texture_2D, 0, GL_STENCIL_INDEX, s_reference_type, s_reference_size, store);
12867 is_ok &= CheckErrorAndLog(
12868 m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12869 "format is STENCIL_INDEX and the base internal format is not STENCIL_INDEX or DEPTH_STENCIL.");
12871 gl.getTextureImage(texture_2D, 0, GL_RED_INTEGER, s_reference_type, s_reference_size, store);
12872 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12873 "format is one of the integer formats in table 8.3 and the internal format of the "
12874 "texture image is not integer.");
12876 gl.getTextureImage(texture_2D_int, 0, GL_RED, s_reference_type, s_reference_size, store);
12877 is_ok &= CheckErrorAndLog(
12878 m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12879 "format is not one of the integer formats in table 8.3 and the internal format is integer.");
12881 /* Check that INVALID_OPERATION error is generated if a pixel pack buffer
12882 object is bound and packing the texture image into the buffer’s memory
12883 would exceed the size of the buffer. */
12884 gl.bindBuffer(GL_PIXEL_PACK_BUFFER, buffer);
12885 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
12887 gl.getTextureImage(texture_2D, 0, s_reference_format, s_reference_type, s_reference_size,
12888 (glw::GLuint*)NULL + 1);
12889 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12890 "a pixel pack buffer object is bound and packing the texture image into the buffer’s "
12891 "memory would exceed the size of the buffer.");
12893 gl.bindBuffer(GL_PIXEL_PACK_BUFFER, 0);
12894 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
12896 /* Check that INVALID_OPERATION error is generated if a pixel pack buffer
12897 object is bound and pixels is not evenly divisible by the number of
12898 basic machine units needed to store in memory the GL data type
12899 corresponding to type (see table 8.2). */
12900 gl.bindBuffer(GL_PIXEL_PACK_BUFFER, buffer);
12901 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
12903 gl.getTextureImage(texture_2D, 0, s_reference_format, s_reference_type, s_reference_size,
12904 (glw::GLubyte*)NULL + 1);
12905 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12906 "a pixel pack buffer object is bound and pixels is not evenly divisible by the "
12907 "number of basic machine units needed to store in memory the GL data type "
12908 "corresponding to type (see table 8.2).");
12910 gl.bindBuffer(GL_PIXEL_PACK_BUFFER, 0);
12911 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
12913 /* Check that INVALID_OPERATION error is generated by GetTextureImage if
12914 the buffer size required to store the requested data is greater than
12916 gl.getTextureImage(texture_2D, 0, s_reference_format, s_reference_type,
12917 s_reference_size - sizeof(s_reference_data[0]), store);
12918 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12919 "the buffer size required to store the requested data is greater than bufSize.");
12921 /* Check that INVALID_OPERATION is generated by GetCompressedTextureImage
12922 if texture is not the name of an existing texture object. */
12923 gl.getCompressedTextureImage(texture_invalid, 0, s_reference_size, store);
12924 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetCompressedTextureImage",
12925 "texture is not the name of an existing texture object.");
12927 /* Check that INVALID_VALUE is generated by GetCompressedTextureImage if
12928 level is less than zero or greater than the maximum number of LODs
12929 permitted by the implementation. */
12930 gl.getCompressedTextureImage(texture_2D_compressed, -1, s_reference_size, store);
12932 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glGetCompressedTextureImage", "level is less than zero.");
12934 gl.getCompressedTextureImage(texture_2D_compressed, max_level, s_reference_size, store);
12935 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glGetCompressedTextureImage",
12936 "level is greater than the maximum number of LODs permitted by the implementation.");
12938 /* Check that INVALID_OPERATION is generated if GetCompressedTextureImage
12939 is used to retrieve a texture that is in an uncompressed internal
12941 gl.getCompressedTextureImage(texture_2D, 0, s_reference_size, store);
12943 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetCompressedTextureImage",
12944 "the function is used to retrieve a texture that is in an uncompressed internal format.");
12946 /* Check that INVALID_OPERATION is generated by GetCompressedTextureImage
12947 if a non-zero buffer object name is bound to the PIXEL_PACK_BUFFER
12948 target, the buffer storage was not initialized with BufferStorage using
12949 MAP_PERSISTENT_BIT flag, and the buffer object's data store is currently
12951 gl.bindBuffer(GL_PIXEL_PACK_BUFFER, buffer);
12952 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
12954 gl.mapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_WRITE);
12956 if (GL_NO_ERROR == gl.getError())
12958 gl.getCompressedTextureImage(texture_2D_compressed, 0, s_reference_size, NULL);
12959 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetCompressedTextureImage",
12960 "a non-zero buffer object name is bound to the PIXEL_PACK_BUFFER target, the "
12961 "buffer storage was not initialized with BufferStorage using MAP_PERSISTENT_BIT "
12962 "flag, and the buffer object's data store is currently mapped.");
12964 gl.unmapBuffer(GL_PIXEL_PACK_BUFFER);
12965 GLU_EXPECT_NO_ERROR(gl.getError(), "glUnmapBuffer has failed");
12972 gl.bindBuffer(GL_PIXEL_PACK_BUFFER, 0);
12973 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
12975 /* Check that INVALID_OPERATION is generated by GetCompressedTextureImage
12976 if a non-zero buffer object name is bound to the PIXEL_PACK_BUFFER
12977 target and the data would be packed to the buffer object such that the
12978 memory writes required would exceed the data store size. */
12979 gl.bindBuffer(GL_PIXEL_PACK_BUFFER, buffer);
12980 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
12982 gl.getCompressedTextureImage(texture_2D_compressed, 0, s_reference_size, (char*)NULL + s_reference_size - 1);
12983 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetCompressedTextureImage",
12984 "a non-zero buffer object name is bound to the PIXEL_PACK_BUFFER target and the data "
12985 "would be packed to the buffer object such that the memory writes required would "
12986 "exceed the data store size.");
12988 gl.bindBuffer(GL_PIXEL_PACK_BUFFER, 0);
12989 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
13000 gl.deleteBuffers(1, &buffer);
13005 gl.deleteTextures(1, &texture_2D);
13008 if (texture_2D_int)
13010 gl.deleteTextures(1, &texture_2D_int);
13013 if (texture_2D_stencil)
13015 gl.deleteTextures(1, &texture_2D_stencil);
13020 gl.deleteTextures(1, &texture_2D_ms);
13023 if (texture_2D_compressed)
13025 gl.deleteTextures(1, &texture_2D_compressed);
13030 gl.deleteTextures(1, &texture_cube);
13033 if (texture_rectangle)
13035 gl.deleteTextures(1, &texture_rectangle);
13038 while (GL_NO_ERROR != gl.getError())
13041 /* Result's setup. */
13044 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
13050 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
13054 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
13061 /******************************** Level Parameter Query Errors Test Implementation ********************************/
13063 /** @brief Image Query Errors Test constructor.
13065 * @param [in] context OpenGL context.
13067 LevelParameterErrorsTest::LevelParameterErrorsTest(deqp::Context& context)
13068 : deqp::TestCase(context, "textures_level_parameter_errors", "Texture Level Parameter Query Errors Test")
13070 /* Intentionally left blank. */
13073 /** @brief Iterate Level Parameter Query Errors Test cases.
13075 * @return Iteration result.
13077 tcu::TestNode::IterateResult LevelParameterErrorsTest::iterate()
13079 /* Shortcut for GL functionality. */
13080 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
13082 /* Get context setup. */
13083 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
13084 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
13086 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
13088 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
13093 /* Running tests. */
13095 bool is_error = false;
13098 glw::GLuint texture_2D = 0;
13099 glw::GLuint texture_invalid = 0;
13100 glw::GLint max_level = 0;
13101 glw::GLenum pname_invalid = 0;
13103 glw::GLfloat storef[4] = {};
13104 glw::GLint storei[4] = {};
13108 /* Preparations. */
13111 gl.genTextures(1, &texture_2D);
13112 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
13114 gl.bindTexture(GL_TEXTURE_2D, texture_2D);
13115 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
13117 gl.texStorage2D(GL_TEXTURE_2D, 1, GL_R8, 1, 1);
13118 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
13121 gl.getIntegerv(GL_MAX_TEXTURE_SIZE, &max_level); /* assuming that x > log(x) */
13122 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
13124 /* invalid texture */
13125 while (gl.isTexture(++texture_invalid))
13128 /* invalid pname */
13129 glw::GLenum all_pnames[] = { GL_TEXTURE_WIDTH,
13132 GL_TEXTURE_SAMPLES,
13133 GL_TEXTURE_FIXED_SAMPLE_LOCATIONS,
13134 GL_TEXTURE_INTERNAL_FORMAT,
13135 GL_TEXTURE_RED_SIZE,
13136 GL_TEXTURE_GREEN_SIZE,
13137 GL_TEXTURE_BLUE_SIZE,
13138 GL_TEXTURE_ALPHA_SIZE,
13139 GL_TEXTURE_DEPTH_SIZE,
13140 GL_TEXTURE_STENCIL_SIZE,
13141 GL_TEXTURE_SHARED_SIZE,
13142 GL_TEXTURE_RED_TYPE,
13143 GL_TEXTURE_GREEN_TYPE,
13144 GL_TEXTURE_BLUE_TYPE,
13145 GL_TEXTURE_ALPHA_TYPE,
13146 GL_TEXTURE_DEPTH_TYPE,
13147 GL_TEXTURE_COMPRESSED,
13148 GL_TEXTURE_COMPRESSED_IMAGE_SIZE,
13149 GL_TEXTURE_BUFFER_DATA_STORE_BINDING,
13150 GL_TEXTURE_BUFFER_OFFSET,
13151 GL_TEXTURE_BUFFER_SIZE };
13153 glw::GLuint all_pnames_count = sizeof(all_pnames) / sizeof(all_pnames[0]);
13155 bool is_valid = true;
13163 for (glw::GLuint i = 0; i < all_pnames_count; ++i)
13165 if (all_pnames[i] == pname_invalid)
13176 /* Check that INVALID_OPERATION is generated by GetTextureLevelParameterfv
13177 and GetTextureLevelParameteriv functions if texture is not the name of
13178 an existing texture object. */
13179 gl.getTextureLevelParameterfv(texture_invalid, 0, GL_TEXTURE_WIDTH, storef);
13180 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureLevelParameterfv",
13181 "texture is not the name of an existing texture object.");
13183 gl.getTextureLevelParameteriv(texture_invalid, 0, GL_TEXTURE_WIDTH, storei);
13184 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureLevelParameteriv",
13185 "texture is not the name of an existing texture object.");
13187 /* Check that INVALID_VALUE is generated by GetTextureLevelParameter* if
13188 level is less than 0. */
13189 gl.getTextureLevelParameterfv(texture_2D, -1, GL_TEXTURE_WIDTH, storef);
13190 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glGetTextureLevelParameterfv", "level is less than 0.");
13192 gl.getTextureLevelParameteriv(texture_2D, -1, GL_TEXTURE_WIDTH, storei);
13193 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glGetTextureLevelParameteriv", "level is less than 0.");
13195 /* Check that INVALID_ENUM error is generated by GetTextureLevelParameter*
13196 if pname is not one of supported constants. */
13197 gl.getTextureLevelParameterfv(texture_2D, 0, pname_invalid, storef);
13198 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glGetTextureLevelParameterfv",
13199 "pname is not one of supported constants.");
13201 gl.getTextureLevelParameteriv(texture_2D, 0, pname_invalid, storei);
13202 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glGetTextureLevelParameteriv",
13203 "pname is not one of supported constants.");
13205 /* Check that INVALID_VALUE may be generated if level is greater than
13206 log2 max, where max is the returned value of MAX_TEXTURE_SIZE. */
13207 gl.getTextureLevelParameterfv(texture_2D, max_level, GL_TEXTURE_WIDTH, storef);
13209 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glGetTextureLevelParameterfv",
13210 "level is greater than log2 max, where max is the returned value of MAX_TEXTURE_SIZE.");
13212 gl.getTextureLevelParameteriv(texture_2D, max_level, GL_TEXTURE_WIDTH, storei);
13214 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glGetTextureLevelParameteriv",
13215 "level is greater than log2 max, where max is the returned value of MAX_TEXTURE_SIZE.");
13217 /* Check that INVALID_OPERATION is generated by GetTextureLevelParameter*
13218 if TEXTURE_COMPRESSED_IMAGE_SIZE is queried on texture images with an
13219 uncompressed internal format or on proxy targets. */
13220 gl.getTextureLevelParameterfv(texture_2D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, storef);
13221 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureLevelParameterfv",
13222 "TEXTURE_COMPRESSED_IMAGE_SIZE is queried on texture images with an uncompressed "
13223 "internal format or on proxy targets.");
13225 gl.getTextureLevelParameteriv(texture_2D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, storei);
13226 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureLevelParameteriv",
13227 "TEXTURE_COMPRESSED_IMAGE_SIZE is queried on texture images with an uncompressed "
13228 "internal format or on proxy targets.");
13239 gl.deleteTextures(1, &texture_2D);
13242 while (GL_NO_ERROR != gl.getError())
13245 /* Result's setup. */
13248 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
13254 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
13258 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
13265 /******************************** Parameter Query Errors Test Implementation ********************************/
13267 /** @brief Parameter Query Errors Test constructor.
13269 * @param [in] context OpenGL context.
13271 ParameterErrorsTest::ParameterErrorsTest(deqp::Context& context)
13272 : deqp::TestCase(context, "textures_parameter_errors", "Texture Parameter Query Errors Test")
13274 /* Intentionally left blank. */
13277 /** @brief Iterate Parameter Query Errors Test cases.
13279 * @return Iteration result.
13281 tcu::TestNode::IterateResult ParameterErrorsTest::iterate()
13283 /* Shortcut for GL functionality. */
13284 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
13286 /* Get context setup. */
13287 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
13288 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
13290 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
13292 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
13297 /* Running tests. */
13299 bool is_error = false;
13302 glw::GLuint texture_2D = 0;
13303 glw::GLuint texture_buffer = 0;
13304 glw::GLuint texture_invalid = 0;
13305 glw::GLenum pname_invalid = 0;
13307 glw::GLfloat storef[4] = {};
13308 glw::GLint storei[4] = {};
13309 glw::GLuint storeu[4] = {};
13313 /* Preparations. */
13316 gl.createTextures(GL_TEXTURE_2D, 1, &texture_2D);
13317 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
13319 /* Buffer texture */
13320 gl.createTextures(GL_TEXTURE_BUFFER, 1, &texture_buffer);
13321 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
13323 /* invalid texture */
13324 while (gl.isTexture(++texture_invalid))
13327 /* invalid pname */
13328 glw::GLenum all_pnames[] = { GL_IMAGE_FORMAT_COMPATIBILITY_TYPE,
13329 GL_TEXTURE_IMMUTABLE_FORMAT,
13330 GL_TEXTURE_IMMUTABLE_LEVELS,
13332 GL_TEXTURE_VIEW_MIN_LEVEL,
13333 GL_TEXTURE_VIEW_NUM_LEVELS,
13334 GL_TEXTURE_VIEW_MIN_LAYER,
13335 GL_TEXTURE_VIEW_NUM_LAYERS,
13336 GL_DEPTH_STENCIL_TEXTURE_MODE,
13337 GL_DEPTH_COMPONENT,
13339 GL_TEXTURE_BASE_LEVEL,
13340 GL_TEXTURE_BORDER_COLOR,
13341 GL_TEXTURE_COMPARE_MODE,
13342 GL_TEXTURE_COMPARE_FUNC,
13343 GL_TEXTURE_LOD_BIAS,
13344 GL_TEXTURE_MAG_FILTER,
13345 GL_TEXTURE_MAX_LEVEL,
13346 GL_TEXTURE_MAX_LOD,
13347 GL_TEXTURE_MIN_FILTER,
13348 GL_TEXTURE_MIN_LOD,
13349 GL_TEXTURE_SWIZZLE_R,
13350 GL_TEXTURE_SWIZZLE_G,
13351 GL_TEXTURE_SWIZZLE_B,
13352 GL_TEXTURE_SWIZZLE_A,
13353 GL_TEXTURE_SWIZZLE_RGBA,
13356 GL_TEXTURE_WRAP_R };
13358 glw::GLuint all_pnames_count = sizeof(all_pnames) / sizeof(all_pnames[0]);
13360 bool is_valid = true;
13368 for (glw::GLuint i = 0; i < all_pnames_count; ++i)
13370 if (all_pnames[i] == pname_invalid)
13381 /* Check that INVALID_ENUM is generated by glGetTextureParameter* if pname
13382 is not an accepted value. */
13383 gl.getTextureParameterfv(texture_2D, pname_invalid, storef);
13385 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glGetTextureParameterfv", "pname is not an accepted value.");
13387 gl.getTextureParameterIiv(texture_2D, pname_invalid, storei);
13389 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glGetTextureParameterIiv", "pname is not an accepted value.");
13391 gl.getTextureParameterIuiv(texture_2D, pname_invalid, storeu);
13392 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glGetTextureParameterIuiv",
13393 "pname is not an accepted value.");
13395 gl.getTextureParameteriv(texture_2D, pname_invalid, storei);
13397 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glGetTextureParameteriv", "pname is not an accepted value.");
13399 /* Check that INVALID_OPERATION is generated by glGetTextureParameter* if
13400 texture is not the name of an existing texture object. */
13401 gl.getTextureParameterfv(texture_invalid, GL_TEXTURE_TARGET, storef);
13402 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureParameterfv",
13403 "texture is not the name of an existing texture object.");
13405 gl.getTextureParameterIiv(texture_invalid, GL_TEXTURE_TARGET, storei);
13406 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureParameterIiv",
13407 "texture is not the name of an existing texture object.");
13409 gl.getTextureParameterIuiv(texture_invalid, GL_TEXTURE_TARGET, storeu);
13410 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureParameterIuiv",
13411 "texture is not the name of an existing texture object.");
13413 gl.getTextureParameteriv(texture_invalid, GL_TEXTURE_TARGET, storei);
13414 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureParameteriv",
13415 "texture is not the name of an existing texture object.");
13417 /* Check that INVALID_OPERATION error is generated if the effective target is
13418 not one of the supported texture targets (eg. TEXTURE_BUFFER). */
13419 gl.getTextureParameterfv(texture_buffer, GL_TEXTURE_TARGET, storef);
13421 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureParameterfv",
13422 "the effective target is not one of the supported texture targets (eg. TEXTURE_BUFFER).");
13424 gl.getTextureParameterIiv(texture_buffer, GL_TEXTURE_TARGET, storei);
13426 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureParameterIiv",
13427 "the effective target is not one of the supported texture targets (eg. TEXTURE_BUFFER).");
13429 gl.getTextureParameterIuiv(texture_buffer, GL_TEXTURE_TARGET, storeu);
13431 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureParameterIuiv",
13432 "the effective target is not one of the supported texture targets (eg. TEXTURE_BUFFER).");
13434 gl.getTextureParameteriv(texture_buffer, GL_TEXTURE_TARGET, storei);
13436 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureParameteriv",
13437 "the effective target is not one of the supported texture targets (eg. TEXTURE_BUFFER).");
13448 gl.deleteTextures(1, &texture_2D);
13451 if (texture_buffer)
13453 gl.deleteTextures(1, &texture_buffer);
13456 while (GL_NO_ERROR != gl.getError())
13459 /* Result's setup. */
13462 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
13468 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
13472 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
13479 } /* Textures namespace. */
13480 } /* DirectStateAccess namespace. */
13481 } /* gl4cts namespace. */