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.
1464 * @tparam N Is normalized.
1465 * @tparam D Texture dimension.
1466 * @tparam I Choose between SubImage and Storage tests.
1468 * @param [in] context OpenGL context.
1469 * @param [in] name Name of the test.
1471 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
1472 StorageAndSubImageTest<T, S, N, D, I>::StorageAndSubImageTest(deqp::Context& context, const char* name)
1473 : deqp::TestCase(context, name, "Texture Storage and SubImage Test")
1480 /* Intentionally left blank. */
1483 /** @brief Count of reference data to be teted.
1487 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
1488 glw::GLuint StorageAndSubImageTest<T, S, N, D, I>::TestReferenceDataCount()
1490 return 2 /* 1D */ * ((D > 1) ? 3 : 1) /* 2D */ * ((D > 2) ? 4 : 1) /* 3D */ * S /* components */;
1493 /** @brief Size of reference data to be teted.
1496 * @tparam S Size (# of components).
1497 * @tparam D Texture dimenisons.
1501 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
1502 glw::GLuint StorageAndSubImageTest<T, S, N, D, I>::TestReferenceDataSize()
1504 return static_cast<glw::GLint>(TestReferenceDataCount() * sizeof(T));
1507 /** @brief Height, width or depth of reference data to be teted.
1509 * @return Height, width or depth.
1511 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
1512 glw::GLuint StorageAndSubImageTest<T, S, N, D, I>::TestReferenceDataHeight()
1524 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
1525 glw::GLuint StorageAndSubImageTest<T, S, N, D, I>::TestReferenceDataDepth()
1536 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
1537 glw::GLuint StorageAndSubImageTest<T, S, N, D, I>::TestReferenceDataWidth()
1542 /** @brief Fragment shader declaration selector.
1544 * @return Frgment shader source code part.
1546 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
1547 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::FragmentShaderDeclaration()
1549 if (typeid(T) == typeid(glw::GLbyte))
1554 return s_fragment_shader_1D_idecl_lowp;
1556 return s_fragment_shader_2D_idecl_lowp;
1558 return s_fragment_shader_3D_idecl_lowp;
1560 DE_ASSERT("invalid texture dimension");
1565 if (typeid(T) == typeid(glw::GLubyte))
1572 return s_fragment_shader_1D_fdecl_lowp;
1574 return s_fragment_shader_2D_fdecl_lowp;
1576 return s_fragment_shader_3D_fdecl_lowp;
1578 DE_ASSERT("invalid texture dimension");
1587 return s_fragment_shader_1D_udecl_lowp;
1589 return s_fragment_shader_2D_udecl_lowp;
1591 return s_fragment_shader_3D_udecl_lowp;
1593 DE_ASSERT("invalid texture dimension");
1599 if (typeid(T) == typeid(glw::GLshort))
1604 return s_fragment_shader_1D_idecl_mediump;
1606 return s_fragment_shader_2D_idecl_mediump;
1608 return s_fragment_shader_3D_idecl_mediump;
1610 DE_ASSERT("invalid texture dimension");
1615 if (typeid(T) == typeid(glw::GLushort))
1622 return s_fragment_shader_1D_fdecl_mediump;
1624 return s_fragment_shader_2D_fdecl_mediump;
1626 return s_fragment_shader_3D_fdecl_mediump;
1628 DE_ASSERT("invalid texture dimension");
1637 return s_fragment_shader_1D_udecl_mediump;
1639 return s_fragment_shader_2D_udecl_mediump;
1641 return s_fragment_shader_3D_udecl_mediump;
1643 DE_ASSERT("invalid texture dimension");
1649 if (typeid(T) == typeid(glw::GLint))
1654 return s_fragment_shader_1D_idecl_highp;
1656 return s_fragment_shader_2D_idecl_highp;
1658 return s_fragment_shader_3D_idecl_highp;
1660 DE_ASSERT("invalid texture dimension");
1665 if (typeid(T) == typeid(glw::GLuint))
1670 return s_fragment_shader_1D_udecl_highp;
1672 return s_fragment_shader_2D_udecl_highp;
1674 return s_fragment_shader_3D_udecl_highp;
1676 DE_ASSERT("invalid texture dimension");
1684 return s_fragment_shader_1D_fdecl_highp;
1686 return s_fragment_shader_2D_fdecl_highp;
1688 return s_fragment_shader_3D_fdecl_highp;
1690 DE_ASSERT("invalid texture dimension");
1695 /** @brief Fragment shader tail selector.
1697 * @tparam D Texture dimenisons.
1699 * @return Frgment shader source code part.
1701 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
1702 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::FragmentShaderTail()
1707 return s_fragment_shader_1D_tail;
1709 return s_fragment_shader_2D_tail;
1711 return s_fragment_shader_3D_tail;
1713 DE_ASSERT("invalid texture dimension");
1718 /** @brief Texture target selector.
1720 * @tparam D Texture dimenisons.
1722 * @return Texture target.
1724 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
1725 glw::GLenum StorageAndSubImageTest<T, S, N, D, I>::TextureTarget()
1730 return GL_TEXTURE_1D;
1732 return GL_TEXTURE_2D;
1734 return GL_TEXTURE_3D;
1736 DE_ASSERT("invalid texture dimension");
1741 /** @brief TextureStorage* wrapper.
1743 * @return true if succeed (in legacy always or throw), false otherwise.
1745 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
1746 bool StorageAndSubImageTest<T, S, N, D, I>::TextureStorage(glw::GLenum target, glw::GLuint texture, glw::GLsizei levels,
1747 glw::GLenum internalformat, glw::GLsizei width,
1748 glw::GLsizei height, glw::GLsizei depth)
1750 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1757 gl.texStorage1D(target, levels, internalformat, width);
1760 gl.texStorage2D(target, levels, internalformat, width, height);
1763 gl.texStorage3D(target, levels, internalformat, width, height, depth);
1766 DE_ASSERT("invalid texture dimension");
1769 /* TextureSubImage* (not TextureStorage*) is tested */
1770 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage*() has failed");
1778 gl.textureStorage1D(texture, levels, internalformat, width);
1781 gl.textureStorage2D(texture, levels, internalformat, width, height);
1784 gl.textureStorage3D(texture, levels, internalformat, width, height, depth);
1787 DE_ASSERT("invalid texture dimension");
1791 if (GL_NO_ERROR != (error = gl.getError()))
1793 m_context.getTestContext().getLog()
1794 << tcu::TestLog::Message << "glTextureStorage" << D << "D unexpectedly generated error " << glu::getErrorStr(error)
1795 << " during test with levels " << levels << ", internal format " << internalformat
1796 << " width=" << width << " height=" << height << " depth=" << depth
1797 << "." << tcu::TestLog::EndMessage;
1809 /** @brief TextureSubImage* wrapper.
1811 * @return true if suuceed (in legacy always or throw), false otherwise.
1813 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
1814 bool StorageAndSubImageTest<T, S, N, D, I>::TextureSubImage(glw::GLenum target, glw::GLuint texture, glw::GLint level,
1815 glw::GLsizei width, glw::GLsizei height, glw::GLsizei depth,
1816 glw::GLenum format, glw::GLenum type, const glw::GLvoid* data)
1818 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1825 gl.textureSubImage1D(texture, level, 0, width, format, type, data);
1828 gl.textureSubImage2D(texture, level, 0, 0, width, height, format, type, data);
1831 gl.textureSubImage3D(texture, level, 0, 0, 0, width, height, depth, format, type, data);
1834 DE_ASSERT("invalid texture dimension");
1838 if (GL_NO_ERROR != (error = gl.getError()))
1840 m_context.getTestContext().getLog()
1841 << tcu::TestLog::Message << "glTextureSubImage" << D << "D unexpectedly generated error " << glu::getErrorStr(error)
1842 << " during test with level " << level << ", width=" << width << ", height=" << height << ", depth=" << depth
1843 << " format " << glu::getTextureFormatStr(format) << " and type " << glu::getTypeStr(type) << "."
1844 << tcu::TestLog::EndMessage;
1859 gl.texSubImage1D(target, level, 0, width, format, type, data);
1862 gl.texSubImage2D(target, level, 0, 0, width, height, format, type, data);
1865 gl.texSubImage3D(target, level, 0, 0, 0, width, height, depth, format, type, data);
1868 DE_ASSERT("invalid texture dimension");
1871 /* TextureStorage* (not TextureSubImage) is tested */
1872 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexSubImage*() has failed");
1877 /** @brief Create texture.
1880 * @tparam S Size (# of components).
1881 * @tparam N Is normalized.
1882 * @tparam D Dimmensions.
1883 * @tparam I Test SubImage or Storage.
1885 * @return True if succeded, false otherwise.
1887 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
1888 bool StorageAndSubImageTest<T, S, N, D, I>::CreateTexture()
1890 /* Shortcut for GL functionality. */
1891 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1893 /* Objects creation. */
1894 gl.genTextures(1, &m_to);
1895 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
1897 gl.bindTexture(TextureTarget(), m_to);
1898 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
1900 /* Storage creation. */
1901 if (TextureStorage(TextureTarget(), m_to, 1, InternalFormat<T, S, N>(), TestReferenceDataWidth(),
1902 TestReferenceDataHeight(), TestReferenceDataDepth()))
1905 if (TextureSubImage(TextureTarget(), m_to, 0, TestReferenceDataWidth(), TestReferenceDataHeight(), TestReferenceDataDepth(),
1906 Format<S, N>(), Type<T>(), ReferenceData<T, N>()))
1908 glTexParameteri(TextureTarget(), GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1909 glTexParameteri(TextureTarget(), GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1919 /** @brief Compre results with the reference.
1921 * @return True if equal, false otherwise.
1923 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
1924 bool StorageAndSubImageTest<T, S, N, D, I>::Check()
1926 /* Shortcut for GL functionality. */
1927 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1929 /* Fetching data. */
1930 std::vector<T> result(TestReferenceDataCount());
1932 glw::GLuint fbo_size_x = 0;
1943 fbo_size_x = 2 * 3 * 4;
1949 gl.readnPixels(0, 0, fbo_size_x, 1, Format<S, N>(), Type<T>(), TestReferenceDataSize(),
1950 (glw::GLvoid*)(&result[0]));
1951 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels has failed");
1954 for (glw::GLuint i = 0; i < TestReferenceDataCount(); ++i)
1956 if (!Compare<T>(result[i], ReferenceData<T, N>()[i]))
1965 /** @brief Test case function.
1967 * @return True if test succeeded, false otherwise.
1969 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
1970 bool StorageAndSubImageTest<T, S, N, D, I>::Test()
1972 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1974 gl.pixelStorei(GL_UNPACK_ALIGNMENT, sizeof(T));
1975 GLU_EXPECT_NO_ERROR(gl.getError(), "glPixelStorei has failed");
1977 gl.pixelStorei(GL_PACK_ALIGNMENT, sizeof(T));
1978 GLU_EXPECT_NO_ERROR(gl.getError(), "glPixelStorei has failed");
1981 PrepareFramebuffer(InternalFormat<T, S, N>());
1983 if (!CreateTexture())
1991 /* Compare results with reference. */
1992 bool result = Check();
2003 /** @brief Function prepares framebuffer with internal format color attachment.
2004 * Viewport is set up. Content of the framebuffer is cleared.
2006 * @note The function may throw if unexpected error has occured.
2008 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2009 void StorageAndSubImageTest<T, S, N, D, I>::PrepareFramebuffer(const glw::GLenum internal_format)
2011 /* Shortcut for GL functionality. */
2012 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2014 /* Prepare framebuffer. */
2015 gl.genFramebuffers(1, &m_fbo);
2016 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
2018 gl.genRenderbuffers(1, &m_rbo);
2019 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
2021 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
2022 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
2024 gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo);
2025 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
2027 glw::GLuint fbo_size_x = 0;
2038 fbo_size_x = 2 * 3 * 4;
2044 gl.renderbufferStorage(GL_RENDERBUFFER, internal_format, fbo_size_x, 1);
2045 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage call failed.");
2047 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo);
2048 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer call failed.");
2050 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
2052 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_UNSUPPORTED)
2053 throw tcu::NotSupportedError("unsupported framebuffer configuration");
2058 gl.viewport(0, 0, fbo_size_x, 1);
2059 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
2061 /* Clear framebuffer's content. */
2062 gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
2063 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor call failed.");
2065 gl.clear(GL_COLOR_BUFFER_BIT);
2066 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear call failed.");
2069 /** @brief Prepare program
2071 * @param [in] variable_declaration Variables declaration part of fragment shader source code.
2072 * @param [in] tail Tail part of fragment shader source code.
2074 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2075 void StorageAndSubImageTest<T, S, N, D, I>::PrepareProgram(const glw::GLchar* variable_declaration, const glw::GLchar* tail)
2077 /* Shortcut for GL functionality */
2078 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2082 glw::GLchar const* source[3];
2083 glw::GLsizei const count;
2084 glw::GLenum const type;
2086 } shader[] = { { { s_vertex_shader, NULL, NULL }, 1, GL_VERTEX_SHADER, 0 },
2087 { { s_fragment_shader_head, variable_declaration, tail }, 3, GL_FRAGMENT_SHADER, 0 } };
2089 glw::GLuint const shader_count = sizeof(shader) / sizeof(shader[0]);
2093 /* Create program. */
2094 m_po = gl.createProgram();
2095 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateProgram call failed.");
2097 /* Shader compilation. */
2099 for (glw::GLuint i = 0; i < shader_count; ++i)
2102 shader[i].id = gl.createShader(shader[i].type);
2104 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateShader call failed.");
2106 gl.attachShader(m_po, shader[i].id);
2108 GLU_EXPECT_NO_ERROR(gl.getError(), "glAttachShader call failed.");
2110 gl.shaderSource(shader[i].id, shader[i].count, shader[i].source, NULL);
2112 GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource call failed.");
2114 gl.compileShader(shader[i].id);
2116 GLU_EXPECT_NO_ERROR(gl.getError(), "glCompileShader call failed.");
2118 glw::GLint status = GL_FALSE;
2120 gl.getShaderiv(shader[i].id, GL_COMPILE_STATUS, &status);
2121 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv call failed.");
2123 if (GL_FALSE == status)
2125 glw::GLint log_size = 0;
2126 gl.getShaderiv(shader[i].id, GL_INFO_LOG_LENGTH, &log_size);
2127 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv call failed.");
2129 glw::GLchar* log_text = new glw::GLchar[log_size];
2131 gl.getShaderInfoLog(shader[i].id, log_size, NULL, &log_text[0]);
2133 m_context.getTestContext().getLog()
2134 << tcu::TestLog::Message << "Shader compilation has failed.\n"
2135 << "Shader type: " << glu::getShaderTypeStr(shader[i].type) << "\n"
2136 << "Shader compilation error log:\n"
2138 << "Shader source code:\n"
2139 << shader[i].source[0] << (shader[i].source[1] ? shader[i].source[1] : "")
2140 << (shader[i].source[2] ? shader[i].source[2] : "") << "\n"
2141 << tcu::TestLog::EndMessage;
2145 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderInfoLog call failed.");
2153 gl.linkProgram(m_po);
2155 GLU_EXPECT_NO_ERROR(gl.getError(), "glTransformFeedbackVaryings call failed.");
2157 glw::GLint status = GL_FALSE;
2159 gl.getProgramiv(m_po, GL_LINK_STATUS, &status);
2161 if (GL_TRUE == status)
2163 for (glw::GLuint i = 0; i < shader_count; ++i)
2167 gl.detachShader(m_po, shader[i].id);
2169 GLU_EXPECT_NO_ERROR(gl.getError(), "glDetachShader call failed.");
2175 glw::GLint log_size = 0;
2177 gl.getProgramiv(m_po, GL_INFO_LOG_LENGTH, &log_size);
2179 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramiv call failed.");
2181 glw::GLchar* log_text = new glw::GLchar[log_size];
2183 gl.getProgramInfoLog(m_po, log_size, NULL, &log_text[0]);
2185 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Program linkage has failed due to:\n"
2187 << tcu::TestLog::EndMessage;
2191 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramInfoLog call failed.");
2200 gl.deleteProgram(m_po);
2206 for (glw::GLuint i = 0; i < shader_count; ++i)
2208 if (0 != shader[i].id)
2210 gl.deleteShader(shader[i].id);
2222 /** @brief Prepare VAO.
2224 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2225 void StorageAndSubImageTest<T, S, N, D, I>::PrepareVertexArray()
2227 /* Shortcut for GL functionality. */
2228 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2230 gl.genVertexArrays(1, &m_vao);
2231 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays has failed");
2233 gl.bindVertexArray(m_vao);
2234 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray has failed");
2237 /** @brief Test's draw call.
2239 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2240 void StorageAndSubImageTest<T, S, N, D, I>::Draw()
2242 /* Shortcut for GL functionality. */
2243 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2245 gl.useProgram(m_po);
2246 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram has failed");
2248 gl.activeTexture(GL_TEXTURE0);
2249 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
2251 gl.bindTextureUnit(0, m_to);
2252 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
2254 gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
2255 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays has failed");
2258 /** @brief Clean GL objects, test variables and GL errors.
2260 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2261 void StorageAndSubImageTest<T, S, N, D, I>::CleanTexture()
2263 /* Shortcut for GL functionality. */
2264 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2269 gl.deleteTextures(1, &m_to);
2275 /** @brief Clean GL objects, test variables and GL errors.
2277 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2278 void StorageAndSubImageTest<T, S, N, D, I>::CleanFramebuffer()
2280 /* Shortcut for GL functionality. */
2281 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2286 gl.deleteFramebuffers(1, &m_fbo);
2294 gl.deleteRenderbuffers(1, &m_rbo);
2300 /** @brief Clean GL objects, test variables and GL errors.
2302 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2303 void StorageAndSubImageTest<T, S, N, D, I>::CleanProgram()
2305 /* Shortcut for GL functionality. */
2306 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2313 gl.deleteProgram(m_po);
2319 /** @brief Clean GL objects, test variables and GL errors.
2321 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2322 void StorageAndSubImageTest<T, S, N, D, I>::CleanErrors()
2324 /* Shortcut for GL functionality. */
2325 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2327 /* Query all errors until GL_NO_ERROR occure. */
2328 while (GL_NO_ERROR != gl.getError())
2332 /** @brief Clean GL objects, test variables and GL errors.
2334 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2335 void StorageAndSubImageTest<T, S, N, D, I>::CleanVertexArray()
2337 /* Shortcut for GL functionality. */
2338 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2342 gl.bindVertexArray(0);
2344 gl.deleteVertexArrays(1, &m_vao);
2350 /** @brief Iterate Storage Test cases.
2352 * @return Iteration result.
2354 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2355 tcu::TestNode::IterateResult StorageAndSubImageTest<T, S, N, D, I>::iterate()
2357 /* Shortcut for GL functionality. */
2358 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2360 /* Get context setup. */
2361 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
2362 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
2364 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
2366 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
2371 /* Running tests. */
2373 bool is_error = false;
2377 PrepareVertexArray();
2378 PrepareProgram(FragmentShaderDeclaration(), FragmentShaderTail());
2381 catch (tcu::NotSupportedError e)
2398 /* Errors clean up. */
2399 while (gl.getError())
2402 /* Result's setup. */
2405 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
2411 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
2415 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
2422 /* Vertex shader source code. */
2423 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2424 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_vertex_shader =
2429 " switch(gl_VertexID)\n"
2432 " gl_Position = vec4(-1.0, 1.0, 0.0, 1.0);\n"
2435 " gl_Position = vec4( 1.0, 1.0, 0.0, 1.0);\n"
2438 " gl_Position = vec4(-1.0,-1.0, 0.0, 1.0);\n"
2441 " gl_Position = vec4( 1.0,-1.0, 0.0, 1.0);\n"
2446 /* Fragment shader source program. */
2447 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2448 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_head =
2451 "layout(pixel_center_integer) in vec4 gl_FragCoord;\n"
2454 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2455 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_1D_fdecl_lowp =
2456 "uniform sampler1D texture_input;\nout vec4 texture_output;\n";
2457 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2458 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_1D_idecl_lowp =
2459 "uniform isampler1D texture_input;\nout ivec4 texture_output;\n";
2460 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2461 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_1D_udecl_lowp =
2462 "uniform usampler1D texture_input;\nout uvec4 texture_output;\n";
2463 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2464 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_1D_fdecl_mediump =
2465 "uniform sampler1D texture_input;\nout vec4 texture_output;\n";
2466 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2467 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_1D_idecl_mediump =
2468 "uniform isampler1D texture_input;\nout ivec4 texture_output;\n";
2469 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2470 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_1D_udecl_mediump =
2471 "uniform usampler1D texture_input;\nout uvec4 texture_output;\n";
2472 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2473 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_1D_fdecl_highp =
2474 "uniform sampler1D texture_input;\nout vec4 texture_output;\n";
2475 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2476 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_1D_idecl_highp =
2477 "uniform isampler1D texture_input;\nout ivec4 texture_output;\n";
2478 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2479 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_1D_udecl_highp =
2480 "uniform usampler1D texture_input;\nout uvec4 texture_output;\n";
2482 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2483 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_2D_fdecl_lowp =
2484 "uniform sampler2D texture_input;\nout vec4 texture_output;\n";
2485 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2486 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_2D_idecl_lowp =
2487 "uniform isampler2D texture_input;\nout ivec4 texture_output;\n";
2488 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2489 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_2D_udecl_lowp =
2490 "uniform usampler2D texture_input;\nout uvec4 texture_output;\n";
2491 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2492 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_2D_fdecl_mediump =
2493 "uniform sampler2D texture_input;\nout vec4 texture_output;\n";
2494 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2495 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_2D_idecl_mediump =
2496 "uniform isampler2D texture_input;\nout ivec4 texture_output;\n";
2497 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2498 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_2D_udecl_mediump =
2499 "uniform usampler2D texture_input;\nout uvec4 texture_output;\n";
2500 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2501 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_2D_fdecl_highp =
2502 "uniform sampler2D texture_input;\nout vec4 texture_output;\n";
2503 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2504 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_2D_idecl_highp =
2505 "uniform isampler2D texture_input;\nout ivec4 texture_output;\n";
2506 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2507 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_2D_udecl_highp =
2508 "uniform usampler2D texture_input;\nout uvec4 texture_output;\n";
2510 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2511 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_3D_fdecl_lowp =
2512 "uniform sampler3D texture_input;\nout vec4 texture_output;\n";
2513 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2514 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_3D_idecl_lowp =
2515 "uniform isampler3D texture_input;\nout ivec4 texture_output;\n";
2516 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2517 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_3D_udecl_lowp =
2518 "uniform usampler3D texture_input;\nout uvec4 texture_output;\n";
2519 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2520 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_3D_fdecl_mediump =
2521 "uniform sampler3D texture_input;\nout vec4 texture_output;\n";
2522 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2523 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_3D_idecl_mediump =
2524 "uniform isampler3D texture_input;\nout ivec4 texture_output;\n";
2525 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2526 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_3D_udecl_mediump =
2527 "uniform usampler3D texture_input;\nout uvec4 texture_output;\n";
2528 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2529 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_3D_fdecl_highp =
2530 "uniform sampler3D texture_input;\nout vec4 texture_output;\n";
2531 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2532 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_3D_idecl_highp =
2533 "uniform isampler3D texture_input;\nout ivec4 texture_output;\n";
2534 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2535 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_3D_udecl_highp =
2536 "uniform usampler3D texture_input;\nout uvec4 texture_output;\n";
2538 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2539 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_1D_tail =
2543 " texture_output = texelFetch(texture_input, int(gl_FragCoord.x), 0);\n"
2546 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2547 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_2D_tail =
2551 " texture_output = texelFetch(texture_input, ivec2(int(gl_FragCoord.x) % 2, int(floor(gl_FragCoord.x / 2))), "
2555 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2556 const glw::GLchar* StorageAndSubImageTest<T, S, N, D, I>::s_fragment_shader_3D_tail =
2560 " texture_output = texelFetch(texture_input, ivec3(int(gl_FragCoord.x) % 2, int(floor(gl_FragCoord.x / 2)) % 3, "
2561 "int(floor(gl_FragCoord.x / 2 / 3))), 0);\n"
2564 template class StorageAndSubImageTest<glw::GLbyte, 1, false, 1, false>;
2565 template class StorageAndSubImageTest<glw::GLbyte, 2, false, 1, false>;
2566 template class StorageAndSubImageTest<glw::GLbyte, 4, false, 1, false>;
2567 template class StorageAndSubImageTest<glw::GLbyte, 1, false, 2, false>;
2568 template class StorageAndSubImageTest<glw::GLbyte, 2, false, 2, false>;
2569 template class StorageAndSubImageTest<glw::GLbyte, 4, false, 2, false>;
2570 template class StorageAndSubImageTest<glw::GLbyte, 1, false, 3, false>;
2571 template class StorageAndSubImageTest<glw::GLbyte, 2, false, 3, false>;
2572 template class StorageAndSubImageTest<glw::GLbyte, 4, false, 3, false>;
2574 template class StorageAndSubImageTest<glw::GLubyte, 1, false, 1, false>;
2575 template class StorageAndSubImageTest<glw::GLubyte, 2, false, 1, false>;
2576 template class StorageAndSubImageTest<glw::GLubyte, 4, false, 1, false>;
2577 template class StorageAndSubImageTest<glw::GLubyte, 1, false, 2, false>;
2578 template class StorageAndSubImageTest<glw::GLubyte, 2, false, 2, false>;
2579 template class StorageAndSubImageTest<glw::GLubyte, 4, false, 2, false>;
2580 template class StorageAndSubImageTest<glw::GLubyte, 1, false, 3, false>;
2581 template class StorageAndSubImageTest<glw::GLubyte, 2, false, 3, false>;
2582 template class StorageAndSubImageTest<glw::GLubyte, 4, false, 3, false>;
2584 template class StorageAndSubImageTest<glw::GLubyte, 1, true, 1, false>;
2585 template class StorageAndSubImageTest<glw::GLubyte, 2, true, 1, false>;
2586 template class StorageAndSubImageTest<glw::GLubyte, 4, true, 1, false>;
2587 template class StorageAndSubImageTest<glw::GLubyte, 1, true, 2, false>;
2588 template class StorageAndSubImageTest<glw::GLubyte, 2, true, 2, false>;
2589 template class StorageAndSubImageTest<glw::GLubyte, 4, true, 2, false>;
2590 template class StorageAndSubImageTest<glw::GLubyte, 1, true, 3, false>;
2591 template class StorageAndSubImageTest<glw::GLubyte, 2, true, 3, false>;
2592 template class StorageAndSubImageTest<glw::GLubyte, 4, true, 3, false>;
2594 template class StorageAndSubImageTest<glw::GLshort, 1, false, 1, false>;
2595 template class StorageAndSubImageTest<glw::GLshort, 2, false, 1, false>;
2596 template class StorageAndSubImageTest<glw::GLshort, 4, false, 1, false>;
2597 template class StorageAndSubImageTest<glw::GLshort, 1, false, 2, false>;
2598 template class StorageAndSubImageTest<glw::GLshort, 2, false, 2, false>;
2599 template class StorageAndSubImageTest<glw::GLshort, 4, false, 2, false>;
2600 template class StorageAndSubImageTest<glw::GLshort, 1, false, 3, false>;
2601 template class StorageAndSubImageTest<glw::GLshort, 2, false, 3, false>;
2602 template class StorageAndSubImageTest<glw::GLshort, 4, false, 3, false>;
2604 template class StorageAndSubImageTest<glw::GLushort, 1, false, 1, false>;
2605 template class StorageAndSubImageTest<glw::GLushort, 2, false, 1, false>;
2606 template class StorageAndSubImageTest<glw::GLushort, 4, false, 1, false>;
2607 template class StorageAndSubImageTest<glw::GLushort, 1, false, 2, false>;
2608 template class StorageAndSubImageTest<glw::GLushort, 2, false, 2, false>;
2609 template class StorageAndSubImageTest<glw::GLushort, 4, false, 2, false>;
2610 template class StorageAndSubImageTest<glw::GLushort, 1, false, 3, false>;
2611 template class StorageAndSubImageTest<glw::GLushort, 2, false, 3, false>;
2612 template class StorageAndSubImageTest<glw::GLushort, 4, false, 3, false>;
2614 template class StorageAndSubImageTest<glw::GLushort, 1, true, 1, false>;
2615 template class StorageAndSubImageTest<glw::GLushort, 2, true, 1, false>;
2616 template class StorageAndSubImageTest<glw::GLushort, 4, true, 1, false>;
2617 template class StorageAndSubImageTest<glw::GLushort, 1, true, 2, false>;
2618 template class StorageAndSubImageTest<glw::GLushort, 2, true, 2, false>;
2619 template class StorageAndSubImageTest<glw::GLushort, 4, true, 2, false>;
2620 template class StorageAndSubImageTest<glw::GLushort, 1, true, 3, false>;
2621 template class StorageAndSubImageTest<glw::GLushort, 2, true, 3, false>;
2622 template class StorageAndSubImageTest<glw::GLushort, 4, true, 3, false>;
2624 template class StorageAndSubImageTest<glw::GLint, 1, false, 1, false>;
2625 template class StorageAndSubImageTest<glw::GLint, 2, false, 1, false>;
2626 template class StorageAndSubImageTest<glw::GLint, 3, false, 1, false>;
2627 template class StorageAndSubImageTest<glw::GLint, 4, false, 1, false>;
2628 template class StorageAndSubImageTest<glw::GLint, 1, false, 2, false>;
2629 template class StorageAndSubImageTest<glw::GLint, 2, false, 2, false>;
2630 template class StorageAndSubImageTest<glw::GLint, 3, false, 2, false>;
2631 template class StorageAndSubImageTest<glw::GLint, 4, false, 2, false>;
2632 template class StorageAndSubImageTest<glw::GLint, 1, false, 3, false>;
2633 template class StorageAndSubImageTest<glw::GLint, 2, false, 3, false>;
2634 template class StorageAndSubImageTest<glw::GLint, 3, false, 3, false>;
2635 template class StorageAndSubImageTest<glw::GLint, 4, false, 3, false>;
2637 template class StorageAndSubImageTest<glw::GLuint, 1, false, 1, false>;
2638 template class StorageAndSubImageTest<glw::GLuint, 2, false, 1, false>;
2639 template class StorageAndSubImageTest<glw::GLuint, 3, false, 1, false>;
2640 template class StorageAndSubImageTest<glw::GLuint, 4, false, 1, false>;
2641 template class StorageAndSubImageTest<glw::GLuint, 1, false, 2, false>;
2642 template class StorageAndSubImageTest<glw::GLuint, 2, false, 2, false>;
2643 template class StorageAndSubImageTest<glw::GLuint, 3, false, 2, false>;
2644 template class StorageAndSubImageTest<glw::GLuint, 4, false, 2, false>;
2645 template class StorageAndSubImageTest<glw::GLuint, 1, false, 3, false>;
2646 template class StorageAndSubImageTest<glw::GLuint, 2, false, 3, false>;
2647 template class StorageAndSubImageTest<glw::GLuint, 3, false, 3, false>;
2648 template class StorageAndSubImageTest<glw::GLuint, 4, false, 3, false>;
2650 template class StorageAndSubImageTest<glw::GLfloat, 1, true, 1, false>;
2651 template class StorageAndSubImageTest<glw::GLfloat, 2, true, 1, false>;
2652 template class StorageAndSubImageTest<glw::GLfloat, 3, true, 1, false>;
2653 template class StorageAndSubImageTest<glw::GLfloat, 4, true, 1, false>;
2654 template class StorageAndSubImageTest<glw::GLfloat, 1, true, 2, false>;
2655 template class StorageAndSubImageTest<glw::GLfloat, 2, true, 2, false>;
2656 template class StorageAndSubImageTest<glw::GLfloat, 3, true, 2, false>;
2657 template class StorageAndSubImageTest<glw::GLfloat, 4, true, 2, false>;
2658 template class StorageAndSubImageTest<glw::GLfloat, 1, true, 3, false>;
2659 template class StorageAndSubImageTest<glw::GLfloat, 2, true, 3, false>;
2660 template class StorageAndSubImageTest<glw::GLfloat, 3, true, 3, false>;
2661 template class StorageAndSubImageTest<glw::GLfloat, 4, true, 3, false>;
2663 template class StorageAndSubImageTest<glw::GLbyte, 1, false, 1, true>;
2664 template class StorageAndSubImageTest<glw::GLbyte, 2, false, 1, true>;
2665 template class StorageAndSubImageTest<glw::GLbyte, 4, false, 1, true>;
2666 template class StorageAndSubImageTest<glw::GLbyte, 1, false, 2, true>;
2667 template class StorageAndSubImageTest<glw::GLbyte, 2, false, 2, true>;
2668 template class StorageAndSubImageTest<glw::GLbyte, 4, false, 2, true>;
2669 template class StorageAndSubImageTest<glw::GLbyte, 1, false, 3, true>;
2670 template class StorageAndSubImageTest<glw::GLbyte, 2, false, 3, true>;
2671 template class StorageAndSubImageTest<glw::GLbyte, 4, false, 3, true>;
2673 template class StorageAndSubImageTest<glw::GLubyte, 1, false, 1, true>;
2674 template class StorageAndSubImageTest<glw::GLubyte, 2, false, 1, true>;
2675 template class StorageAndSubImageTest<glw::GLubyte, 4, false, 1, true>;
2676 template class StorageAndSubImageTest<glw::GLubyte, 1, false, 2, true>;
2677 template class StorageAndSubImageTest<glw::GLubyte, 2, false, 2, true>;
2678 template class StorageAndSubImageTest<glw::GLubyte, 4, false, 2, true>;
2679 template class StorageAndSubImageTest<glw::GLubyte, 1, false, 3, true>;
2680 template class StorageAndSubImageTest<glw::GLubyte, 2, false, 3, true>;
2681 template class StorageAndSubImageTest<glw::GLubyte, 4, false, 3, true>;
2683 template class StorageAndSubImageTest<glw::GLubyte, 1, true, 1, true>;
2684 template class StorageAndSubImageTest<glw::GLubyte, 2, true, 1, true>;
2685 template class StorageAndSubImageTest<glw::GLubyte, 4, true, 1, true>;
2686 template class StorageAndSubImageTest<glw::GLubyte, 1, true, 2, true>;
2687 template class StorageAndSubImageTest<glw::GLubyte, 2, true, 2, true>;
2688 template class StorageAndSubImageTest<glw::GLubyte, 4, true, 2, true>;
2689 template class StorageAndSubImageTest<glw::GLubyte, 1, true, 3, true>;
2690 template class StorageAndSubImageTest<glw::GLubyte, 2, true, 3, true>;
2691 template class StorageAndSubImageTest<glw::GLubyte, 4, true, 3, true>;
2693 template class StorageAndSubImageTest<glw::GLshort, 1, false, 1, true>;
2694 template class StorageAndSubImageTest<glw::GLshort, 2, false, 1, true>;
2695 template class StorageAndSubImageTest<glw::GLshort, 4, false, 1, true>;
2696 template class StorageAndSubImageTest<glw::GLshort, 1, false, 2, true>;
2697 template class StorageAndSubImageTest<glw::GLshort, 2, false, 2, true>;
2698 template class StorageAndSubImageTest<glw::GLshort, 4, false, 2, true>;
2699 template class StorageAndSubImageTest<glw::GLshort, 1, false, 3, true>;
2700 template class StorageAndSubImageTest<glw::GLshort, 2, false, 3, true>;
2701 template class StorageAndSubImageTest<glw::GLshort, 4, false, 3, true>;
2703 template class StorageAndSubImageTest<glw::GLushort, 1, false, 1, true>;
2704 template class StorageAndSubImageTest<glw::GLushort, 2, false, 1, true>;
2705 template class StorageAndSubImageTest<glw::GLushort, 4, false, 1, true>;
2706 template class StorageAndSubImageTest<glw::GLushort, 1, false, 2, true>;
2707 template class StorageAndSubImageTest<glw::GLushort, 2, false, 2, true>;
2708 template class StorageAndSubImageTest<glw::GLushort, 4, false, 2, true>;
2709 template class StorageAndSubImageTest<glw::GLushort, 1, false, 3, true>;
2710 template class StorageAndSubImageTest<glw::GLushort, 2, false, 3, true>;
2711 template class StorageAndSubImageTest<glw::GLushort, 4, false, 3, true>;
2713 template class StorageAndSubImageTest<glw::GLushort, 1, true, 1, true>;
2714 template class StorageAndSubImageTest<glw::GLushort, 2, true, 1, true>;
2715 template class StorageAndSubImageTest<glw::GLushort, 4, true, 1, true>;
2716 template class StorageAndSubImageTest<glw::GLushort, 1, true, 2, true>;
2717 template class StorageAndSubImageTest<glw::GLushort, 2, true, 2, true>;
2718 template class StorageAndSubImageTest<glw::GLushort, 4, true, 2, true>;
2719 template class StorageAndSubImageTest<glw::GLushort, 1, true, 3, true>;
2720 template class StorageAndSubImageTest<glw::GLushort, 2, true, 3, true>;
2721 template class StorageAndSubImageTest<glw::GLushort, 4, true, 3, true>;
2723 template class StorageAndSubImageTest<glw::GLint, 1, false, 1, true>;
2724 template class StorageAndSubImageTest<glw::GLint, 2, false, 1, true>;
2725 template class StorageAndSubImageTest<glw::GLint, 3, false, 1, true>;
2726 template class StorageAndSubImageTest<glw::GLint, 4, false, 1, true>;
2727 template class StorageAndSubImageTest<glw::GLint, 1, false, 2, true>;
2728 template class StorageAndSubImageTest<glw::GLint, 2, false, 2, true>;
2729 template class StorageAndSubImageTest<glw::GLint, 3, false, 2, true>;
2730 template class StorageAndSubImageTest<glw::GLint, 4, false, 2, true>;
2731 template class StorageAndSubImageTest<glw::GLint, 1, false, 3, true>;
2732 template class StorageAndSubImageTest<glw::GLint, 2, false, 3, true>;
2733 template class StorageAndSubImageTest<glw::GLint, 3, false, 3, true>;
2734 template class StorageAndSubImageTest<glw::GLint, 4, false, 3, true>;
2736 template class StorageAndSubImageTest<glw::GLuint, 1, false, 1, true>;
2737 template class StorageAndSubImageTest<glw::GLuint, 2, false, 1, true>;
2738 template class StorageAndSubImageTest<glw::GLuint, 3, false, 1, true>;
2739 template class StorageAndSubImageTest<glw::GLuint, 4, false, 1, true>;
2740 template class StorageAndSubImageTest<glw::GLuint, 1, false, 2, true>;
2741 template class StorageAndSubImageTest<glw::GLuint, 2, false, 2, true>;
2742 template class StorageAndSubImageTest<glw::GLuint, 3, false, 2, true>;
2743 template class StorageAndSubImageTest<glw::GLuint, 4, false, 2, true>;
2744 template class StorageAndSubImageTest<glw::GLuint, 1, false, 3, true>;
2745 template class StorageAndSubImageTest<glw::GLuint, 2, false, 3, true>;
2746 template class StorageAndSubImageTest<glw::GLuint, 3, false, 3, true>;
2747 template class StorageAndSubImageTest<glw::GLuint, 4, false, 3, true>;
2749 template class StorageAndSubImageTest<glw::GLfloat, 1, true, 1, true>;
2750 template class StorageAndSubImageTest<glw::GLfloat, 2, true, 1, true>;
2751 template class StorageAndSubImageTest<glw::GLfloat, 3, true, 1, true>;
2752 template class StorageAndSubImageTest<glw::GLfloat, 4, true, 1, true>;
2753 template class StorageAndSubImageTest<glw::GLfloat, 1, true, 2, true>;
2754 template class StorageAndSubImageTest<glw::GLfloat, 2, true, 2, true>;
2755 template class StorageAndSubImageTest<glw::GLfloat, 3, true, 2, true>;
2756 template class StorageAndSubImageTest<glw::GLfloat, 4, true, 2, true>;
2757 template class StorageAndSubImageTest<glw::GLfloat, 1, true, 3, true>;
2758 template class StorageAndSubImageTest<glw::GLfloat, 2, true, 3, true>;
2759 template class StorageAndSubImageTest<glw::GLfloat, 3, true, 3, true>;
2760 template class StorageAndSubImageTest<glw::GLfloat, 4, true, 3, true>;
2762 /******************************** Storage Multisample Test Implementation ********************************/
2764 /** @brief Storage Multisample Test constructor.
2766 * @param [in] context OpenGL context.
2768 StorageMultisampleTest::StorageMultisampleTest(deqp::Context& context)
2769 : deqp::TestCase(context, "textures_storage_multisample", "Texture Storage Multisample Test")
2779 /* Intentionally left blank. */
2782 /** @brief Count of reference data to be teted.
2784 * @tparam S Size (# of components).
2785 * @tparam D Texture dimenisons.
2789 template <glw::GLint S, glw::GLuint D>
2790 glw::GLuint StorageMultisampleTest::TestReferenceDataCount()
2792 return 2 /* 1D */ * ((D > 1) ? 3 : 1) /* 2D */ * ((D > 2) ? 4 : 1) /* 3D */ * S /* components */;
2795 /** @brief Size of reference data to be teted.
2798 * @tparam S Size (# of components).
2799 * @tparam D Texture dimenisons.
2803 template <typename T, glw::GLint S, glw::GLuint D>
2804 glw::GLuint StorageMultisampleTest::TestReferenceDataSize()
2806 return TestReferenceDataCount<S, D>() * sizeof(T);
2809 /** @brief Height, width or depth of reference data to be teted.
2811 * @tparam D Texture dimenisons.
2813 * @return Height, width or depth.
2816 glw::GLuint StorageMultisampleTest::TestReferenceDataHeight<2>()
2822 glw::GLuint StorageMultisampleTest::TestReferenceDataHeight<3>()
2824 return TestReferenceDataHeight<2>();
2828 glw::GLuint StorageMultisampleTest::TestReferenceDataDepth<2>()
2834 glw::GLuint StorageMultisampleTest::TestReferenceDataDepth<3>()
2839 template <glw::GLuint D>
2840 glw::GLuint StorageMultisampleTest::TestReferenceDataWidth()
2845 /** @brief Fragment shader declaration selector.
2848 * @tparam N Normalized flag.
2849 * @tparam D Texture dimenisons.
2851 * @return Frgment shader source code part.
2854 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLubyte, true, 2>()
2856 return s_fragment_shader_ms_2D_fdecl_lowp;
2860 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLbyte, false, 2>()
2862 return s_fragment_shader_ms_2D_idecl_lowp;
2866 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLubyte, false, 2>()
2868 return s_fragment_shader_ms_2D_udecl_lowp;
2872 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLushort, true, 2>()
2874 return s_fragment_shader_ms_2D_fdecl_mediump;
2878 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLshort, false, 2>()
2880 return s_fragment_shader_ms_2D_idecl_mediump;
2884 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLushort, false, 2>()
2886 return s_fragment_shader_ms_2D_udecl_mediump;
2890 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLfloat, true, 2>()
2892 return s_fragment_shader_ms_2D_fdecl_highp;
2896 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLint, false, 2>()
2898 return s_fragment_shader_ms_2D_idecl_highp;
2902 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLuint, false, 2>()
2904 return s_fragment_shader_ms_2D_udecl_highp;
2907 /** @brief Fragment shader declaration selector.
2910 * @tparam N Normalized flag.
2911 * @tparam D Texture dimenisons.
2913 * @return Frgment shader source code part.
2916 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLubyte, true, 3>()
2918 return s_fragment_shader_ms_3D_fdecl_lowp;
2922 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLbyte, false, 3>()
2924 return s_fragment_shader_ms_3D_idecl_lowp;
2928 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLubyte, false, 3>()
2930 return s_fragment_shader_ms_3D_udecl_lowp;
2934 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLushort, true, 3>()
2936 return s_fragment_shader_ms_3D_fdecl_mediump;
2940 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLshort, false, 3>()
2942 return s_fragment_shader_ms_3D_idecl_mediump;
2946 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLushort, false, 3>()
2948 return s_fragment_shader_ms_3D_udecl_mediump;
2952 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLfloat, true, 3>()
2954 return s_fragment_shader_ms_3D_fdecl_highp;
2958 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLint, false, 3>()
2960 return s_fragment_shader_ms_3D_idecl_highp;
2964 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLuint, false, 3>()
2966 return s_fragment_shader_ms_3D_udecl_highp;
2969 /** @brief Fragment shader declaration selector.
2972 * @tparam N Normalized flag.
2973 * @tparam D Texture dimenisons.
2975 * @return Frgment shader source code part.
2978 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLubyte, true, 2>()
2980 return s_fragment_shader_aux_2D_fdecl_lowp;
2984 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLbyte, false, 2>()
2986 return s_fragment_shader_aux_2D_idecl_lowp;
2990 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLubyte, false, 2>()
2992 return s_fragment_shader_aux_2D_udecl_lowp;
2996 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLushort, true, 2>()
2998 return s_fragment_shader_aux_2D_fdecl_mediump;
3002 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLshort, false, 2>()
3004 return s_fragment_shader_aux_2D_idecl_mediump;
3008 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLushort, false, 2>()
3010 return s_fragment_shader_aux_2D_udecl_mediump;
3014 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLfloat, true, 2>()
3016 return s_fragment_shader_aux_2D_fdecl_highp;
3020 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLint, false, 2>()
3022 return s_fragment_shader_aux_2D_idecl_highp;
3026 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLuint, false, 2>()
3028 return s_fragment_shader_aux_2D_udecl_highp;
3031 /** @brief Fragment shader declaration selector.
3034 * @tparam N Normalized flag.
3035 * @tparam D Texture dimenisons.
3037 * @return Frgment shader source code part.
3040 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLubyte, true, 3>()
3042 return s_fragment_shader_aux_3D_fdecl_lowp;
3046 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLbyte, false, 3>()
3048 return s_fragment_shader_aux_3D_idecl_lowp;
3052 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLubyte, false, 3>()
3054 return s_fragment_shader_aux_3D_udecl_lowp;
3058 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLushort, true, 3>()
3060 return s_fragment_shader_aux_3D_fdecl_mediump;
3064 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLshort, false, 3>()
3066 return s_fragment_shader_aux_3D_idecl_mediump;
3070 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLushort, false, 3>()
3072 return s_fragment_shader_aux_3D_udecl_mediump;
3076 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLfloat, true, 3>()
3078 return s_fragment_shader_aux_3D_fdecl_highp;
3082 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLint, false, 3>()
3084 return s_fragment_shader_aux_3D_idecl_highp;
3088 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLuint, false, 3>()
3090 return s_fragment_shader_aux_3D_udecl_highp;
3093 /** @brief Fragment shader tail selector.
3095 * @tparam D Texture dimenisons.
3097 * @return Frgment shader source code part.
3100 const glw::GLchar* StorageMultisampleTest::FragmentShaderTail<2>()
3102 return s_fragment_shader_tail_2D;
3106 const glw::GLchar* StorageMultisampleTest::FragmentShaderTail<3>()
3108 return s_fragment_shader_tail_3D;
3111 /** @brief Texture target selector.
3113 * @tparam D Texture dimenisons.
3115 * @return Texture target.
3118 glw::GLenum StorageMultisampleTest::InputTextureTarget<2>()
3120 return GL_TEXTURE_2D;
3124 glw::GLenum StorageMultisampleTest::InputTextureTarget<3>()
3126 return GL_TEXTURE_2D_ARRAY;
3129 /** @brief Prepare texture data for input texture.
3131 * @tparam D Texture dimenisons.
3133 * @note parameters as passed to texImage*
3136 void StorageMultisampleTest::InputTextureImage<2>(const glw::GLenum internal_format, const glw::GLuint width,
3137 const glw::GLuint height, const glw::GLuint depth,
3138 const glw::GLenum format, const glw::GLenum type,
3139 const glw::GLvoid* data)
3142 /* Shortcut for GL functionality. */
3143 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3146 gl.texImage2D(InputTextureTarget<2>(), 0, internal_format, width, height, 0, format, type, data);
3147 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
3150 /** @brief Prepare texture data for input texture.
3152 * @tparam D Texture dimenisons.
3154 * @note parameters as passed to texImage*
3157 void StorageMultisampleTest::InputTextureImage<3>(const glw::GLenum internal_format, const glw::GLuint width,
3158 const glw::GLuint height, const glw::GLuint depth,
3159 const glw::GLenum format, const glw::GLenum type,
3160 const glw::GLvoid* data)
3162 /* Shortcut for GL functionality. */
3163 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3166 gl.texImage3D(InputTextureTarget<3>(), 0, internal_format, width, height, depth, 0, format, type, data);
3167 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
3170 /** @brief Create texture.
3173 * @tparam S Size (# of components).
3174 * @tparam N Is normalized.
3175 * @tparam D Dimmensions.
3177 template <typename T, glw::GLint S, bool N, glw::GLuint D>
3178 void StorageMultisampleTest::CreateInputTexture()
3180 /* Shortcut for GL functionality. */
3181 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3183 /* Objects creation. */
3184 gl.genTextures(1, &m_to);
3185 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
3187 gl.bindTexture(InputTextureTarget<D>(), m_to);
3188 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
3191 InputTextureImage<D>(InternalFormat<T, S, N>(), TestReferenceDataWidth<D>(), TestReferenceDataHeight<D>(),
3192 TestReferenceDataDepth<D>(), Format<S, N>(), Type<T>(), ReferenceData<T, N>());
3194 /* Parameter setup. */
3195 gl.texParameteri(InputTextureTarget<D>(), GL_TEXTURE_MAG_FILTER, GL_NEAREST);
3196 gl.texParameteri(InputTextureTarget<D>(), GL_TEXTURE_MIN_FILTER, GL_NEAREST);
3197 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri call failed.");
3200 /** @brief Compre results with the reference.
3203 * @tparam S Size (# of components).
3204 * @tparam N Is normalized.
3206 * @return True if equal, false otherwise.
3208 template <typename T, glw::GLint S, bool N, glw::GLuint D>
3209 bool StorageMultisampleTest::Check()
3211 /* Shortcut for GL functionality. */
3212 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3214 /* Fetching data fro auxiliary texture. */
3215 std::vector<T> result(TestReferenceDataCount<S, D>());
3217 gl.bindTexture(InputTextureTarget<D>() /* Auxiliary target is the same as input. */, m_to_aux);
3218 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
3220 gl.getTexImage(InputTextureTarget<D>() /* Auxiliary target is the same as input. */, 0, Format<S, N>(), Type<T>(),
3221 (glw::GLvoid*)(&result[0]));
3222 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexImage has failed");
3225 for (glw::GLuint i = 0; i < TestReferenceDataCount<S, D>(); ++i)
3227 if (!Compare<T>(result[i], ReferenceData<T, N>()[i]))
3236 /** @brief Test case function.
3239 * @tparam S Size (# of components).
3240 * @tparam N Is normalized.
3241 * @tparam D Number of texture dimensions.
3243 * @return True if test succeeded, false otherwise.
3245 template <typename T, glw::GLint S, bool N, glw::GLuint D>
3246 bool StorageMultisampleTest::Test()
3248 /* Shortcut for GL functionality. */
3249 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3252 gl.pixelStorei(GL_UNPACK_ALIGNMENT, sizeof(T));
3253 GLU_EXPECT_NO_ERROR(gl.getError(), "glPixelStorei has failed");
3255 gl.pixelStorei(GL_PACK_ALIGNMENT, sizeof(T));
3256 GLU_EXPECT_NO_ERROR(gl.getError(), "glPixelStorei has failed");
3258 CreateInputTexture<T, S, N, D>();
3260 if (!PrepareFramebufferMultisample<D>(InternalFormat<T, S, N>()))
3262 CleanInputTexture();
3267 PrepareFramebufferAuxiliary<D>(InternalFormat<T, S, N>());
3272 /* Compare results with reference. */
3273 bool result = Check<T, S, N, D>();
3276 CleanAuxiliaryTexture();
3277 CleanFramebuffers();
3278 CleanInputTexture();
3285 /** @brief Lopp test function over S.
3288 * @tparam N Is normalized.
3289 * @tparam D Texture dimension.
3291 * @param [in] skip_rgb Skip test of S = 3 (needed for some formats).
3293 * @return True if tests succeeded, false otherwise.
3295 template <typename T, bool N, glw::GLuint D>
3296 bool StorageMultisampleTest::LoopTestOverS(bool skip_rgb)
3298 /* Prepare one program to create multisample texture and one to copy it to regular texture. */
3299 m_po_ms = PrepareProgram(FragmentShaderDeclarationMultisample<T, N, D>(), FragmentShaderTail<D>());
3300 m_po_aux = PrepareProgram(FragmentShaderDeclarationAuxiliary<T, N, D>(), FragmentShaderTail<D>());
3305 result &= Test<T, 1, N, D>();
3307 result &= Test<T, 2, N, D>();
3311 result &= Test<T, 3, N, D>();
3314 result &= Test<T, 4, N, D>();
3324 /** @brief Lopp test function over D and next over S.
3327 * @tparam N Is normalized.
3329 * @param [in] skip_rgb Skip test of S = 3 (needed for some formats).
3331 * @return True if tests succeeded, false otherwise.
3333 template <typename T, bool N>
3334 bool StorageMultisampleTest::LoopTestOverDOverS(bool skip_rgb)
3338 result &= LoopTestOverS<T, N, 2>(skip_rgb);
3339 result &= LoopTestOverS<T, N, 3>(skip_rgb);
3344 /** @brief Function prepares framebuffer with internal format color attachment.
3345 * Viewport is set up. Content of the framebuffer is cleared.
3347 * @note The function may throw if unexpected error has occured.
3350 bool StorageMultisampleTest::PrepareFramebufferMultisample<2>(const glw::GLenum internal_format)
3352 /* Shortcut for GL functionality. */
3353 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3355 /* Prepare framebuffer. */
3356 gl.genFramebuffers(1, &m_fbo_ms);
3357 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
3359 gl.genTextures(1, &m_to_ms);
3360 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
3362 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_ms);
3363 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
3365 gl.bindTexture(GL_TEXTURE_2D_MULTISAMPLE, m_to_ms);
3366 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
3368 gl.textureStorage2DMultisample(m_to_ms, 1, internal_format, TestReferenceDataWidth<2>(),
3369 TestReferenceDataHeight<2>(), false);
3373 if (GL_NO_ERROR != (error = gl.getError()))
3375 CleanFramebuffers();
3377 m_context.getTestContext().getLog()
3378 << tcu::TestLog::Message << "glTextureStorage2DMultisample unexpectedly generated error "
3379 << glu::getErrorStr(error) << " during the test of internal format "
3380 << glu::getTextureFormatStr(internal_format) << ". Test fails." << tcu::TestLog::EndMessage;
3385 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, m_to_ms, 0);
3386 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer call failed.");
3388 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
3393 gl.viewport(0, 0, TestReferenceDataWidth<2>(), TestReferenceDataHeight<2>());
3394 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
3396 /* Clear framebuffer's content. */
3397 gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
3398 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor call failed.");
3400 gl.clear(GL_COLOR_BUFFER_BIT);
3401 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear call failed.");
3406 /** @brief Function prepares framebuffer with internal format color attachment.
3407 * Viewport is set up. Content of the framebuffer is cleared.
3409 * @note The function may throw if unexpected error has occured.
3412 bool StorageMultisampleTest::PrepareFramebufferMultisample<3>(const glw::GLenum internal_format)
3414 /* Shortcut for GL functionality. */
3415 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3417 /* Prepare framebuffer. */
3418 gl.genFramebuffers(1, &m_fbo_ms);
3419 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
3421 gl.genTextures(1, &m_to_ms);
3422 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
3424 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_ms);
3425 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
3427 gl.bindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, m_to_ms);
3428 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
3430 gl.textureStorage3DMultisample(m_to_ms, 1, internal_format, TestReferenceDataWidth<3>(),
3431 TestReferenceDataHeight<3>(), TestReferenceDataDepth<3>(), false);
3435 if (GL_NO_ERROR != (error = gl.getError()))
3437 CleanFramebuffers();
3439 m_context.getTestContext().getLog()
3440 << tcu::TestLog::Message << "glTextureStorage3DMultisample unexpectedly generated error "
3441 << glu::getErrorStr(error) << " during the test of internal format "
3442 << glu::getTextureFormatStr(internal_format) << ". Test fails." << tcu::TestLog::EndMessage;
3447 for (glw::GLuint i = 0; i < TestReferenceDataDepth<3>(); ++i)
3449 gl.framebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, m_to_ms, 0, i);
3450 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer call failed.");
3453 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
3458 gl.viewport(0, 0, TestReferenceDataWidth<3>(), TestReferenceDataHeight<3>());
3459 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
3461 /* Clear framebuffer's content. */
3462 gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
3463 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor call failed.");
3465 gl.clear(GL_COLOR_BUFFER_BIT);
3466 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear call failed.");
3471 /** @brief Function prepares framebuffer with internal format color attachment.
3472 * Viewport is set up. Content of the framebuffer is cleared.
3474 * @note The function may throw if unexpected error has occured.
3477 void StorageMultisampleTest::PrepareFramebufferAuxiliary<2>(const glw::GLenum internal_format)
3479 /* Shortcut for GL functionality. */
3480 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3482 /* Prepare framebuffer. */
3483 gl.genFramebuffers(1, &m_fbo_aux);
3484 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
3486 gl.genTextures(1, &m_to_aux);
3487 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
3489 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_aux);
3490 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
3492 gl.bindTexture(GL_TEXTURE_2D, m_to_aux);
3493 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
3495 gl.textureStorage2D(m_to_aux, 1, internal_format, TestReferenceDataWidth<2>(), TestReferenceDataHeight<2>());
3496 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage2D call failed.");
3498 /* Parameter setup. */
3499 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
3500 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
3501 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri call failed.");
3503 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_to_aux, 0);
3504 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer call failed.");
3506 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
3511 gl.viewport(0, 0, TestReferenceDataWidth<2>(), TestReferenceDataHeight<2>());
3512 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
3514 /* Clear framebuffer's content. */
3515 gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
3516 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor call failed.");
3518 gl.clear(GL_COLOR_BUFFER_BIT);
3519 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear call failed.");
3522 /** @brief Function prepares framebuffer with internal format color attachment.
3523 * Viewport is set up. Content of the framebuffer is cleared.
3525 * @note The function may throw if unexpected error has occured.
3528 void StorageMultisampleTest::PrepareFramebufferAuxiliary<3>(const glw::GLenum internal_format)
3530 /* Shortcut for GL functionality. */
3531 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3533 /* Prepare framebuffer. */
3534 gl.genFramebuffers(1, &m_fbo_aux);
3535 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
3537 gl.genTextures(1, &m_to_aux);
3538 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
3540 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_aux);
3541 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
3543 gl.bindTexture(GL_TEXTURE_2D_ARRAY, m_to_aux);
3544 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
3546 gl.textureStorage3D(m_to_aux, 1, internal_format, TestReferenceDataWidth<3>(), TestReferenceDataHeight<3>(),
3547 TestReferenceDataDepth<3>());
3548 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage3D call failed.");
3550 /* Parameter setup. */
3551 gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
3552 gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
3553 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri call failed.");
3555 for (glw::GLuint i = 0; i < TestReferenceDataDepth<3>(); ++i)
3557 gl.framebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, m_to_aux, 0, i);
3558 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer call failed.");
3561 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
3566 gl.viewport(0, 0, TestReferenceDataWidth<3>(), TestReferenceDataHeight<3>());
3567 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
3569 /* Clear framebuffer's content. */
3570 gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
3571 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor call failed.");
3573 gl.clear(GL_COLOR_BUFFER_BIT);
3574 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear call failed.");
3577 /** @brief Prepare program
3579 * @param [in] variable_declaration Variables declaration part of fragment shader source code.
3580 * @param [in] tail Tail part of fragment shader source code.
3582 glw::GLuint StorageMultisampleTest::PrepareProgram(const glw::GLchar* variable_declaration, const glw::GLchar* tail)
3584 /* Shortcut for GL functionality */
3585 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3589 glw::GLchar const* source[3];
3590 glw::GLsizei const count;
3591 glw::GLenum const type;
3593 } shader[] = { { { s_vertex_shader, NULL, NULL }, 1, GL_VERTEX_SHADER, 0 },
3594 { { s_fragment_shader_head, variable_declaration, tail }, 3, GL_FRAGMENT_SHADER, 0 } };
3596 glw::GLuint const shader_count = sizeof(shader) / sizeof(shader[0]);
3602 /* Create program. */
3603 po = gl.createProgram();
3604 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateProgram call failed.");
3606 /* Shader compilation. */
3608 for (glw::GLuint i = 0; i < shader_count; ++i)
3611 shader[i].id = gl.createShader(shader[i].type);
3613 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateShader call failed.");
3615 gl.attachShader(po, shader[i].id);
3617 GLU_EXPECT_NO_ERROR(gl.getError(), "glAttachShader call failed.");
3619 gl.shaderSource(shader[i].id, shader[i].count, shader[i].source, NULL);
3621 GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource call failed.");
3623 gl.compileShader(shader[i].id);
3625 GLU_EXPECT_NO_ERROR(gl.getError(), "glCompileShader call failed.");
3627 glw::GLint status = GL_FALSE;
3629 gl.getShaderiv(shader[i].id, GL_COMPILE_STATUS, &status);
3630 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv call failed.");
3632 if (GL_FALSE == status)
3634 glw::GLint log_size = 0;
3635 gl.getShaderiv(shader[i].id, GL_INFO_LOG_LENGTH, &log_size);
3636 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv call failed.");
3638 glw::GLchar* log_text = new glw::GLchar[log_size];
3640 gl.getShaderInfoLog(shader[i].id, log_size, NULL, &log_text[0]);
3642 m_context.getTestContext().getLog()
3643 << tcu::TestLog::Message << "Shader compilation has failed.\n"
3644 << "Shader type: " << glu::getShaderTypeStr(shader[i].type) << "\n"
3645 << "Shader compilation error log:\n"
3647 << "Shader source code:\n"
3648 << shader[i].source[0] << (shader[i].source[1] ? shader[i].source[1] : "")
3649 << (shader[i].source[2] ? shader[i].source[2] : "") << "\n"
3650 << tcu::TestLog::EndMessage;
3654 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderInfoLog call failed.");
3664 GLU_EXPECT_NO_ERROR(gl.getError(), "glTransformFeedbackVaryings call failed.");
3666 glw::GLint status = GL_FALSE;
3668 gl.getProgramiv(po, GL_LINK_STATUS, &status);
3670 if (GL_TRUE == status)
3672 for (glw::GLuint i = 0; i < shader_count; ++i)
3676 gl.detachShader(po, shader[i].id);
3678 GLU_EXPECT_NO_ERROR(gl.getError(), "glDetachShader call failed.");
3684 glw::GLint log_size = 0;
3686 gl.getProgramiv(po, GL_INFO_LOG_LENGTH, &log_size);
3688 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramiv call failed.");
3690 glw::GLchar* log_text = new glw::GLchar[log_size];
3692 gl.getProgramInfoLog(po, log_size, NULL, &log_text[0]);
3694 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Program linkage has failed due to:\n"
3696 << tcu::TestLog::EndMessage;
3700 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramInfoLog call failed.");
3709 gl.deleteProgram(po);
3715 for (glw::GLuint i = 0; i < shader_count; ++i)
3717 if (0 != shader[i].id)
3719 gl.deleteShader(shader[i].id);
3733 /** @brief Prepare VAO.
3735 void StorageMultisampleTest::PrepareVertexArray()
3737 /* Shortcut for GL functionality. */
3738 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3740 gl.genVertexArrays(1, &m_vao);
3741 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays has failed");
3743 gl.bindVertexArray(m_vao);
3744 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray has failed");
3747 /** @brief Draw call 2D.
3750 void StorageMultisampleTest::Draw<2>()
3752 /* Shortcut for GL functionality. */
3753 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3755 /* Prepare multisample texture using draw call. */
3757 /* Prepare framebuffer with multisample texture. */
3758 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_ms);
3759 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
3761 /* Use first program program. */
3762 gl.useProgram(m_po_ms);
3763 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram has failed");
3765 /* Prepare texture to be drawn with. */
3766 gl.activeTexture(GL_TEXTURE0);
3767 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
3769 gl.bindTexture(GL_TEXTURE_2D, m_to);
3770 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
3772 gl.uniform1i(gl.getUniformLocation(m_po_ms, "texture_input"), 0);
3773 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i or glGetUniformLocation has failed");
3776 gl.drawBuffer(GL_COLOR_ATTACHMENT0);
3777 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawBuffer has failed");
3780 gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
3781 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays has failed");
3783 /* Copy multisample texture to auxiliary texture using draw call. */
3785 /* Prepare framebuffer with auxiliary texture. */
3786 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_aux);
3787 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
3789 /* Use first program program. */
3790 gl.useProgram(m_po_aux);
3791 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram has failed");
3793 /* Prepare texture to be drawn with. */
3794 gl.activeTexture(GL_TEXTURE0);
3795 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
3797 gl.bindTexture(GL_TEXTURE_2D_MULTISAMPLE, m_to_ms);
3798 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
3800 gl.bindTextureUnit(0, m_to);
3802 gl.uniform1i(gl.getUniformLocation(m_po_aux, "texture_input"), 0);
3803 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i or glGetUniformLocation has failed");
3806 gl.drawBuffer(GL_COLOR_ATTACHMENT0);
3807 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawBuffer has failed");
3810 gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
3811 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays has failed");
3814 /** @brief Draw call 3D.
3817 void StorageMultisampleTest::Draw<3>()
3819 /* Shortcut for GL functionality. */
3820 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3822 /* Prepare multisample texture using draw call. */
3824 /* Prepare framebuffer with multisample texture. */
3825 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_ms);
3826 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
3828 /* Use first program program. */
3829 gl.useProgram(m_po_ms);
3830 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram has failed");
3832 /* Prepare texture to be drawn with. */
3833 gl.activeTexture(GL_TEXTURE0);
3834 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
3836 gl.bindTexture(GL_TEXTURE_2D_ARRAY, m_to);
3837 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
3839 gl.uniform1i(gl.getUniformLocation(m_po_ms, "texture_input"), 0);
3840 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i or glGetUniformLocation has failed");
3842 /* For each texture layer. */
3843 for (glw::GLuint i = 0; i < TestReferenceDataDepth<3>(); ++i)
3846 gl.drawBuffer(GL_COLOR_ATTACHMENT0 + i);
3847 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawBuffer has failed");
3849 gl.uniform1i(gl.getUniformLocation(m_po_aux, "texture_layer"), i);
3850 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i or glGetUniformLocation has failed");
3853 gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
3854 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays has failed");
3857 /* Copy multisample texture to auxiliary texture using draw call. */
3859 /* Prepare framebuffer with auxiliary texture. */
3860 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_aux);
3861 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
3863 /* Use first program program. */
3864 gl.useProgram(m_po_aux);
3865 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram has failed");
3867 /* Prepare texture to be drawn with. */
3868 gl.activeTexture(GL_TEXTURE0);
3869 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
3871 gl.bindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, m_to_ms);
3872 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
3874 gl.bindTextureUnit(0, m_to);
3876 gl.uniform1i(gl.getUniformLocation(m_po_aux, "texture_input"), 0);
3877 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i or glGetUniformLocation has failed");
3879 /* For each texture layer. */
3880 for (glw::GLuint i = 0; i < TestReferenceDataDepth<3>(); ++i)
3883 gl.drawBuffer(GL_COLOR_ATTACHMENT0 + i);
3884 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawBuffer has failed");
3886 gl.uniform1i(gl.getUniformLocation(m_po_aux, "texture_layer"), i);
3887 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i or glGetUniformLocation has failed");
3890 gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
3891 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays has failed");
3895 /** @brief Clean GL objects, test variables and GL errors.
3897 void StorageMultisampleTest::CleanInputTexture()
3899 /* Shortcut for GL functionality. */
3900 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3905 gl.deleteTextures(1, &m_to);
3911 /** @brief Clean GL objects, test variables and GL errors.
3913 void StorageMultisampleTest::CleanAuxiliaryTexture()
3915 /* Shortcut for GL functionality. */
3916 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3920 gl.deleteTextures(1, &m_to_aux);
3926 /** @brief Clean GL objects, test variables and GL errors.
3928 void StorageMultisampleTest::CleanFramebuffers()
3930 /* Shortcut for GL functionality. */
3931 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3933 /* Mulitsample framebuffer. */
3936 gl.deleteFramebuffers(1, &m_fbo_ms);
3941 /* Mulitsample texture. */
3944 gl.deleteTextures(1, &m_to_ms);
3949 /* Auxiliary framebuffer. */
3952 gl.deleteFramebuffers(1, &m_fbo_aux);
3957 /* Auxiliary texture. */
3960 gl.deleteTextures(1, &m_to_aux);
3966 /** @brief Clean GL objects, test variables and GL errors.
3968 void StorageMultisampleTest::CleanPrograms()
3970 /* Shortcut for GL functionality. */
3971 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3973 /* Binding point. */
3976 /* Multisample texture preparation program. */
3979 gl.deleteProgram(m_po_ms);
3984 /* Auxiliary texture preparation program. */
3987 gl.deleteProgram(m_po_aux);
3993 /** @brief Clean GL objects, test variables and GL errors.
3995 void StorageMultisampleTest::CleanErrors()
3997 /* Shortcut for GL functionality. */
3998 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4000 /* Query all errors until GL_NO_ERROR occure. */
4001 while (GL_NO_ERROR != gl.getError())
4005 /** @brief Clean GL objects, test variables and GL errors.
4007 void StorageMultisampleTest::CleanVertexArray()
4009 /* Shortcut for GL functionality. */
4010 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4014 gl.bindVertexArray(0);
4016 gl.deleteVertexArrays(1, &m_vao);
4022 /** @brief Iterate Storage Multisample Test cases.
4024 * @return Iteration result.
4026 tcu::TestNode::IterateResult StorageMultisampleTest::iterate()
4028 /* Shortcut for GL functionality. */
4029 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4031 /* Get context setup. */
4032 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
4033 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
4035 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
4037 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
4042 /* Running tests. */
4044 bool is_error = false;
4048 PrepareVertexArray();
4050 // gl.enable(GL_MULTISAMPLE);
4052 is_ok &= LoopTestOverDOverS<glw::GLbyte, false>(true);
4053 is_ok &= LoopTestOverDOverS<glw::GLubyte, false>(true);
4054 is_ok &= LoopTestOverDOverS<glw::GLshort, false>(true);
4055 is_ok &= LoopTestOverDOverS<glw::GLushort, false>(true);
4056 is_ok &= LoopTestOverDOverS<glw::GLint, false>(false);
4057 is_ok &= LoopTestOverDOverS<glw::GLuint, false>(false);
4058 is_ok &= LoopTestOverDOverS<glw::GLubyte, true>(true);
4059 is_ok &= LoopTestOverDOverS<glw::GLushort, true>(true);
4060 is_ok &= LoopTestOverDOverS<glw::GLfloat, true>(false);
4069 CleanInputTexture();
4070 CleanAuxiliaryTexture();
4071 CleanFramebuffers();
4075 gl.disable(GL_MULTISAMPLE);
4077 /* Errors clean up. */
4078 while (gl.getError())
4081 /* Result's setup. */
4084 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
4090 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
4094 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
4101 /* Vertex shader source code. */
4102 const glw::GLchar* StorageMultisampleTest::s_vertex_shader = "#version 450\n"
4106 " switch(gl_VertexID)\n"
4109 " gl_Position = vec4(-1.0, 1.0, 0.0, 1.0);\n"
4112 " gl_Position = vec4( 1.0, 1.0, 0.0, 1.0);\n"
4115 " gl_Position = vec4(-1.0,-1.0, 0.0, 1.0);\n"
4118 " gl_Position = vec4( 1.0,-1.0, 0.0, 1.0);\n"
4123 /* Fragment shader source program. */
4124 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_head =
4127 "layout(pixel_center_integer) in vec4 gl_FragCoord;\n"
4130 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_2D_fdecl_lowp =
4131 "uniform sampler2D texture_input;\nout vec4 texture_output;\n";
4132 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_2D_idecl_lowp =
4133 "uniform isampler2D texture_input;\nout ivec4 texture_output;\n";
4134 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_2D_udecl_lowp =
4135 "uniform usampler2D texture_input;\nout uvec4 texture_output;\n";
4136 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_2D_fdecl_mediump =
4137 "uniform sampler2D texture_input;\nout vec4 texture_output;\n";
4138 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_2D_idecl_mediump =
4139 "uniform isampler2D texture_input;\nout ivec4 texture_output;\n";
4140 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_2D_udecl_mediump =
4141 "uniform usampler2D texture_input;\nout uvec4 texture_output;\n";
4142 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_2D_fdecl_highp =
4143 "uniform sampler2D texture_input;\nout vec4 texture_output;\n";
4144 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_2D_idecl_highp =
4145 "uniform isampler2D texture_input;\nout ivec4 texture_output;\n";
4146 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_2D_udecl_highp =
4147 "uniform usampler2D texture_input;\nout uvec4 texture_output;\n";
4149 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_3D_fdecl_lowp =
4150 "uniform sampler2DArray texture_input;\nout vec4 texture_output;\n";
4152 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_3D_idecl_lowp =
4153 "uniform isampler2DArray texture_input;\nout ivec4 texture_output;\n";
4155 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_3D_udecl_lowp =
4156 "uniform usampler2DArray texture_input;\nout uvec4 texture_output;\n";
4158 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_3D_fdecl_mediump =
4159 "uniform sampler2DArray texture_input;\nout vec4 texture_output;\n";
4161 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_3D_idecl_mediump =
4162 "uniform isampler2DArray texture_input;\nout ivec4 texture_output;\n";
4164 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_3D_udecl_mediump =
4165 "uniform usampler2DArray texture_input;\nout uvec4 texture_output;\n";
4167 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_3D_fdecl_highp =
4168 "uniform sampler2DArray texture_input;\nout vec4 texture_output;\n";
4170 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_3D_idecl_highp =
4171 "uniform isampler2DArray texture_input;\nout ivec4 texture_output;\n";
4173 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_3D_udecl_highp =
4174 "uniform usampler2DArray texture_input;\nout uvec4 texture_output;\n";
4176 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_2D_fdecl_lowp =
4177 "uniform sampler2DMS texture_input;\nout vec4 texture_output;\n";
4178 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_2D_idecl_lowp =
4179 "uniform isampler2DMS texture_input;\nout ivec4 texture_output;\n";
4180 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_2D_udecl_lowp =
4181 "uniform usampler2DMS texture_input;\nout uvec4 texture_output;\n";
4183 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_2D_fdecl_mediump =
4184 "uniform sampler2DMS texture_input;\nout vec4 texture_output;\n";
4186 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_2D_idecl_mediump =
4187 "uniform isampler2DMS texture_input;\nout ivec4 texture_output;\n";
4189 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_2D_udecl_mediump =
4190 "uniform usampler2DMS texture_input;\nout uvec4 texture_output;\n";
4192 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_2D_fdecl_highp =
4193 "uniform sampler2DMS texture_input;\nout vec4 texture_output;\n";
4194 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_2D_idecl_highp =
4195 "uniform isampler2DMS texture_input;\nout ivec4 texture_output;\n";
4196 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_2D_udecl_highp =
4197 "uniform usampler2DMS texture_input;\nout uvec4 texture_output;\n";
4199 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_3D_fdecl_lowp =
4200 "uniform sampler2DMSArray texture_input;\nout vec4 texture_output;\n";
4202 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_3D_idecl_lowp =
4203 "uniform isampler2DMSArray texture_input;\nout ivec4 texture_output;\n";
4205 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_3D_udecl_lowp =
4206 "uniform usampler2DMSArray texture_input;\nout uvec4 texture_output;\n";
4208 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_3D_fdecl_mediump =
4209 "uniform sampler2DMSArray texture_input;\nout vec4 texture_output;\n";
4211 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_3D_idecl_mediump =
4212 "uniform isampler2DMSArray texture_input;\nout ivec4 texture_output;\n";
4214 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_3D_udecl_mediump =
4215 "uniform usampler2DMSArray texture_input;\nout uvec4 texture_output;\n";
4217 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_3D_fdecl_highp =
4218 "uniform sampler2DMSArray texture_input;\nout vec4 texture_output;\n";
4220 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_3D_idecl_highp =
4221 "uniform isampler2DMSArray texture_input;\nout ivec4 texture_output;\n";
4223 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_3D_udecl_highp =
4224 "uniform usampler2DMSArray texture_input;\nout uvec4 texture_output;\n";
4226 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_tail_2D =
4230 " texture_output = texelFetch(texture_input, ivec2(gl_FragCoord.xy), 0);\n"
4233 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_tail_3D =
4235 "uniform int texture_layer;\n"
4239 " texture_output = texelFetch(texture_input, ivec3(gl_FragCoord.xy, texture_layer), 0);\n"
4242 /******************************** Compressed SubImage Test Implementation ********************************/
4244 /** @brief Compressed SubImage Test constructor.
4246 * @param [in] context OpenGL context.
4248 CompressedSubImageTest::CompressedSubImageTest(deqp::Context& context)
4249 : deqp::TestCase(context, "textures_compressed_subimage", "Texture Compressed SubImage Test")
4252 , m_compressed_texture_data(DE_NULL)
4253 , m_reference(DE_NULL)
4255 , m_reference_size(0)
4256 , m_reference_internalformat(0)
4258 /* Intentionally left blank. */
4261 /** @brief Create texture.
4263 * @param [in] target Texture target.
4265 void CompressedSubImageTest::CreateTextures(glw::GLenum target)
4267 /* Shortcut for GL functionality. */
4268 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4270 /* Auxiliary texture (for content creation). */
4271 gl.genTextures(1, &m_to_aux);
4272 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
4274 gl.bindTexture(target, m_to_aux);
4275 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
4277 /* Test texture (for data upload). */
4278 gl.genTextures(1, &m_to);
4279 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
4281 gl.bindTexture(target, m_to);
4282 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
4285 /** @brief Texture target selector.
4287 * @tparam D Texture dimenisons.
4289 * @return Texture target.
4292 glw::GLenum CompressedSubImageTest::TextureTarget<1>()
4294 return GL_TEXTURE_1D;
4298 glw::GLenum CompressedSubImageTest::TextureTarget<2>()
4300 return GL_TEXTURE_2D;
4304 glw::GLenum CompressedSubImageTest::TextureTarget<3>()
4306 return GL_TEXTURE_2D_ARRAY;
4309 /** @brief Prepare texture data for the auxiliary texture.
4311 * @tparam D Texture dimenisons.
4313 * @note parameters as passed to texImage*
4316 void CompressedSubImageTest::TextureImage<1>(glw::GLint internalformat)
4318 /* Shortcut for GL functionality. */
4319 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4321 gl.texImage1D(TextureTarget<1>(), 0, internalformat, s_texture_width, 0, GL_RGBA, GL_UNSIGNED_BYTE, s_texture_data);
4322 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
4325 /** @brief Prepare texture data for the auxiliary texture.
4327 * @tparam D Texture dimenisons.
4329 * @note parameters as passed to texImage*
4332 void CompressedSubImageTest::TextureImage<2>(glw::GLint internalformat)
4334 /* Shortcut for GL functionality. */
4335 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4337 gl.texImage2D(TextureTarget<2>(), 0, internalformat, s_texture_width, s_texture_height, 0, GL_RGBA,
4338 GL_UNSIGNED_BYTE, s_texture_data);
4339 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
4342 /** @brief Prepare texture data for the auxiliary texture.
4344 * @tparam D Texture dimenisons.
4346 * @note parameters as passed to texImage*
4349 void CompressedSubImageTest::TextureImage<3>(glw::GLint internalformat)
4351 /* Shortcut for GL functionality. */
4352 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4354 gl.texImage3D(TextureTarget<3>(), 0, internalformat, s_texture_width, s_texture_height, s_texture_depth, 0, GL_RGBA,
4355 GL_UNSIGNED_BYTE, s_texture_data);
4356 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage3D has failed");
4359 /** @brief Prepare texture data for the auxiliary texture.
4361 * @tparam D Texture dimensions.
4363 * @note parameters as passed to compressedTexImage*
4366 void CompressedSubImageTest::CompressedTexImage<1>(glw::GLint internalformat)
4368 /* Shortcut for GL functionality. */
4369 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4371 gl.compressedTexImage1D(TextureTarget<1>(), 0, internalformat, s_texture_width, 0, m_reference_size,
4372 m_compressed_texture_data);
4373 GLU_EXPECT_NO_ERROR(gl.getError(), "glCompressedTexImage1D has failed");
4376 /** @brief Prepare texture data for the auxiliary texture.
4378 * @tparam D Texture dimensions.
4380 * @note parameters as passed to compressedTexImage*
4383 void CompressedSubImageTest::CompressedTexImage<2>(glw::GLint internalformat)
4385 /* Shortcut for GL functionality. */
4386 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4388 gl.compressedTexImage2D(TextureTarget<2>(), 0, internalformat, s_texture_width, s_texture_height, 0,
4389 m_reference_size, m_compressed_texture_data);
4390 GLU_EXPECT_NO_ERROR(gl.getError(), "glCompressedTexImage2D has failed");
4393 /** @brief Prepare texture data for the auxiliary texture.
4395 * @tparam D Texture dimensions.
4397 * @note parameters as passed to compressedTexImage*
4400 void CompressedSubImageTest::CompressedTexImage<3>(glw::GLint internalformat)
4402 /* Shortcut for GL functionality. */
4403 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4405 gl.compressedTexImage3D(TextureTarget<3>(), 0, internalformat, s_texture_width, s_texture_height, s_texture_depth,
4406 0, m_reference_size, m_compressed_texture_data);
4407 GLU_EXPECT_NO_ERROR(gl.getError(), "glCompressedTexImage3D has failed");
4410 /** @brief Prepare texture data for the compressed texture.
4412 * @tparam D Texture dimenisons.
4414 * @param [in] internalformat Texture internal format.
4416 * @return True if tested function succeeded, false otherwise.
4419 bool CompressedSubImageTest::CompressedTextureSubImage<1>(glw::GLint internalformat)
4421 /* Shortcut for GL functionality. */
4422 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4424 /* Load texture image with tested function. */
4425 if (m_reference_size)
4427 for (glw::GLuint block = 0; block < s_block_count; ++block)
4429 gl.compressedTextureSubImage1D(m_to, 0, s_texture_width * block, s_texture_width, internalformat,
4430 m_reference_size, m_compressed_texture_data);
4435 /* For 1D version there is no specific compressed texture internal format spcified in OpenGL 4.5 core profile documentation.
4436 Only implementation depended specific internalformats may provide this functionality. As a result there may be no reference data to be substituted.
4437 Due to this reason there is no use of CompressedTextureSubImage1D and particulary it cannot be tested. */
4444 if (GL_NO_ERROR != (error = gl.getError()))
4446 m_context.getTestContext().getLog()
4447 << tcu::TestLog::Message << "glCompressedTextureSubImage1D unexpectedly generated error "
4448 << glu::getErrorStr(error) << " during the test with internal format "
4449 << glu::getTextureFormatStr(internalformat) << ". Test fails." << tcu::TestLog::EndMessage;
4457 /** @brief Prepare texture data for the compressed texture.
4459 * @tparam D Texture dimenisons.
4461 * @param [in] internalformat Texture internal format.
4463 * @return True if tested function succeeded, false otherwise.
4466 bool CompressedSubImageTest::CompressedTextureSubImage<2>(glw::GLint internalformat)
4468 /* Shortcut for GL functionality. */
4469 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4471 for (glw::GLuint y = 0; y < s_block_2d_size_y; ++y)
4473 for (glw::GLuint x = 0; x < s_block_2d_size_x; ++x)
4475 /* Load texture image with tested function. */
4476 gl.compressedTextureSubImage2D(m_to, 0, s_texture_width * x, s_texture_height * y, s_texture_width,
4477 s_texture_height, internalformat, m_reference_size,
4478 m_compressed_texture_data);
4484 if (GL_NO_ERROR != (error = gl.getError()))
4486 m_context.getTestContext().getLog()
4487 << tcu::TestLog::Message << "glCompressedTextureSubImage2D unexpectedly generated error "
4488 << glu::getErrorStr(error) << " during the test with internal format "
4489 << glu::getTextureFormatStr(internalformat) << ". Test fails." << tcu::TestLog::EndMessage;
4497 /** @brief Prepare texture data for the compressed texture.
4499 * @tparam D Texture dimenisons.
4501 * @param [in] internalformat Texture internal format.
4503 * @return True if tested function succeeded, false otherwise.
4506 bool CompressedSubImageTest::CompressedTextureSubImage<3>(glw::GLint internalformat)
4508 /* Shortcut for GL functionality. */
4509 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4511 for (glw::GLuint z = 0; z < s_block_3d_size; ++z)
4513 for (glw::GLuint y = 0; y < s_block_3d_size; ++y)
4515 for (glw::GLuint x = 0; x < s_block_3d_size; ++x)
4517 /* Load texture image with tested function. */
4518 gl.compressedTextureSubImage3D(m_to, 0, s_texture_width * x, s_texture_height * y, s_texture_depth * z,
4519 s_texture_width, s_texture_height, s_texture_depth, internalformat,
4520 m_reference_size, m_compressed_texture_data);
4528 if (GL_NO_ERROR != (error = gl.getError()))
4530 m_context.getTestContext().getLog()
4531 << tcu::TestLog::Message << "glCompressedTextureSubImage2D unexpectedly generated error "
4532 << glu::getErrorStr(error) << " during the test with internal format "
4533 << glu::getTextureFormatStr(internalformat) << ". Test fails." << tcu::TestLog::EndMessage;
4540 /** @brief Prepare the reference data.
4542 * @tparam D Texture dimenisons.
4544 template <glw::GLuint D>
4545 void CompressedSubImageTest::PrepareReferenceData(glw::GLenum internalformat)
4547 /* Shortcut for GL functionality. */
4548 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4550 /* Using OpenGL to compress raw data. */
4551 gl.bindTexture(TextureTarget<D>(), m_to_aux);
4552 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
4554 TextureImage<D>(internalformat);
4556 /* Sanity checks. */
4557 if ((DE_NULL != m_reference) || (DE_NULL != m_compressed_texture_data))
4562 /* Check that really compressed texture. */
4563 glw::GLint is_compressed_texture = 0;
4564 gl.getTexLevelParameteriv(TextureTarget<D>(), 0, GL_TEXTURE_COMPRESSED, &is_compressed_texture);
4566 if (is_compressed_texture)
4568 /* Query texture size. */
4569 glw::GLint compressed_texture_size = 0;
4570 gl.getTexLevelParameteriv(TextureTarget<D>(), 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &compressed_texture_size);
4572 /* If compressed then download. */
4573 if (compressed_texture_size)
4575 /* Prepare storage. */
4576 m_compressed_texture_data = new glw::GLubyte[compressed_texture_size];
4578 if (DE_NULL != m_compressed_texture_data)
4580 m_reference_size = compressed_texture_size;
4587 /* Download the source compressed texture image. */
4588 gl.getCompressedTexImage(TextureTarget<D>(), 0, m_compressed_texture_data);
4589 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
4591 // Upload the source compressed texture image to the texture object.
4592 // Some compressed texture format can be emulated by the driver (like the ETC2/EAC formats)
4593 // The compressed data sent by CompressedTexImage will be stored uncompressed by the driver
4594 // and will be re-compressed if the application call glGetCompressedTexImage.
4595 // The compression/decompression is not lossless, so when this happen it's possible for the source
4596 // and destination (from glGetCompressedTexImage) compressed data to be different.
4597 // To avoid that we will store both the source (in m_compressed_texture_data) and the destination
4598 // (in m_reference). The destination will be used later to make sure getCompressedTextureSubImage
4599 // return the expected value
4600 CompressedTexImage<D>(internalformat);
4602 m_reference = new glw::GLubyte[m_reference_size];
4604 if (DE_NULL == m_reference)
4609 /* Download compressed texture image. */
4610 gl.getCompressedTexImage(TextureTarget<D>(), 0, m_reference);
4611 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
4616 /** @brief Prepare texture storage.
4618 * @tparam D Texture dimenisons.
4620 * @param [in] internalformat Texture internal format.
4623 void CompressedSubImageTest::PrepareStorage<1>(glw::GLenum internalformat)
4625 /* Shortcut for GL functionality. */
4626 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4628 gl.bindTexture(TextureTarget<1>(), m_to);
4629 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
4631 gl.texImage1D(TextureTarget<1>(), 0, internalformat, s_texture_width * s_block_count, 0, GL_RGBA, GL_UNSIGNED_BYTE,
4633 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
4636 /** @brief Prepare texture storage.
4638 * @tparam D Texture dimenisons.
4640 * @param [in] internalformat Texture internal format.
4643 void CompressedSubImageTest::PrepareStorage<2>(glw::GLenum internalformat)
4645 /* Shortcut for GL functionality. */
4646 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4648 gl.bindTexture(TextureTarget<2>(), m_to);
4649 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
4651 gl.texImage2D(TextureTarget<2>(), 0, internalformat, s_texture_width * s_block_2d_size_x,
4652 s_texture_height * s_block_2d_size_y, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
4653 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
4656 /** @brief Prepare texture storage.
4658 * @tparam D Texture dimenisons.
4660 * @param [in] internalformat Texture internal format.
4663 void CompressedSubImageTest::PrepareStorage<3>(glw::GLenum internalformat)
4665 /* Shortcut for GL functionality. */
4666 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4668 gl.bindTexture(TextureTarget<3>(), m_to);
4669 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
4671 gl.texImage3D(TextureTarget<3>(), 0, internalformat, s_texture_width * s_block_3d_size,
4672 s_texture_height * s_block_3d_size, s_texture_depth * s_block_3d_size, 0, GL_RGBA, GL_UNSIGNED_BYTE,
4674 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
4677 /** @brief Compare results with the reference.
4680 * @tparam S Size (# of components).
4681 * @tparam N Is normalized.
4683 * @param [in] internalformat Texture internal format.
4685 * @return True if equal, false otherwise.
4687 template <glw::GLuint D>
4688 bool CompressedSubImageTest::CheckData(glw::GLenum internalformat)
4690 /* Shortcut for GL functionality. */
4691 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4693 /* Check texture content with reference. */
4694 m_result = new glw::GLubyte[m_reference_size * s_block_count];
4696 if (DE_NULL == m_result)
4701 gl.getCompressedTexImage(TextureTarget<D>(), 0, m_result);
4702 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
4703 for (glw::GLuint block = 0; block < s_block_count; ++block)
4705 for (glw::GLuint i = 0; i < m_reference_size; ++i)
4707 if (m_reference[i] != m_result[block * m_reference_size + i])
4709 m_context.getTestContext().getLog()
4710 << tcu::TestLog::Message << "glCompressedTextureSubImage*D created texture with data "
4711 << DataToString(m_reference_size, m_reference) << " however texture contains data "
4712 << DataToString(m_reference_size, &(m_result[block * m_reference_size])) << ". Texture target was "
4713 << glu::getTextureTargetStr(TextureTarget<D>()) << " and internal format was "
4714 << glu::getTextureFormatStr(internalformat) << ". Test fails." << tcu::TestLog::EndMessage;
4724 /** @brief Compare results with the reference.
4727 * @tparam S Size (# of components).
4728 * @tparam N Is normalized.
4730 * @param [in] internalformat Texture internal format.
4732 * @return True if equal, false otherwise.
4735 bool CompressedSubImageTest::CheckData<3>(glw::GLenum internalformat)
4737 /* Shortcut for GL functionality. */
4738 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4740 /* Check texture content with reference. */
4741 m_result = new glw::GLubyte[m_reference_size * s_block_count];
4743 if (DE_NULL == m_result)
4748 gl.getCompressedTexImage(TextureTarget<3>(), 0, m_result);
4749 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
4751 glw::GLuint reference_layer_size = m_reference_size / s_texture_depth;
4753 for (glw::GLuint i = 0; i < m_reference_size * s_block_count; ++i)
4755 // we will read the result one bytes at the time and compare with the reference
4756 // for each bytes of the result image we need to figure out which byte in the reference image it corresponds to
4757 glw::GLuint refIdx = i % reference_layer_size;
4758 glw::GLuint refLayerIdx = (i / (reference_layer_size * s_block_3d_size * s_block_3d_size)) % s_texture_depth;
4759 if (m_reference[refLayerIdx * reference_layer_size + refIdx] != m_result[i])
4761 m_context.getTestContext().getLog()
4762 << tcu::TestLog::Message << "glCompressedTextureSubImage3D created texture with data "
4763 << DataToString(reference_layer_size, &(m_reference[refLayerIdx * reference_layer_size]))
4764 << " however texture contains data "
4765 << DataToString(reference_layer_size, &(m_result[i % reference_layer_size])) << ". Texture target was "
4766 << glu::getTextureTargetStr(TextureTarget<3>()) << " and internal format was "
4767 << glu::getTextureFormatStr(internalformat) << ". Test fails." << tcu::TestLog::EndMessage;
4775 /** @brief Test case function.
4777 * @tparam D Number of texture dimensions.
4779 * @param [in] internal format Texture internal format.
4781 * @return True if test succeeded, false otherwise.
4783 template <glw::GLuint D>
4784 bool CompressedSubImageTest::Test(glw::GLenum internalformat)
4786 /* Create texture image. */
4787 CreateTextures(TextureTarget<D>());
4788 PrepareReferenceData<D>(internalformat);
4789 PrepareStorage<D>(internalformat);
4791 /* Setup data with CompressedTextureSubImage<D>D function and check for errors. */
4792 if (!CompressedTextureSubImage<D>(internalformat))
4799 /* If compressed reference data was generated than compare values. */
4802 if (!CheckData<D>(internalformat))
4815 /** @brief Clean GL objects, test variables and GL errors.
4817 void CompressedSubImageTest::CleanAll()
4819 /* Shortcut for GL functionality. */
4820 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4825 gl.deleteTextures(1, &m_to);
4832 gl.deleteTextures(1, &m_to_aux);
4837 /* Reference data storage. */
4838 if (DE_NULL != m_reference)
4840 delete[] m_reference;
4842 m_reference = DE_NULL;
4845 if (DE_NULL != m_compressed_texture_data)
4847 delete[] m_compressed_texture_data;
4849 m_compressed_texture_data = DE_NULL;
4852 if (DE_NULL != m_result)
4859 m_reference_size = 0;
4862 while (GL_NO_ERROR != gl.getError())
4866 /** @brief Convert raw data into string for logging purposes.
4868 * @param [in] count Count of the data.
4869 * @param [in] data Raw data.
4871 * @return String representation of data.
4873 std::string CompressedSubImageTest::DataToString(glw::GLuint count, const glw::GLubyte data[])
4875 std::string data_str = "[";
4877 for (glw::GLuint i = 0; i < count; ++i)
4879 std::stringstream int_sstream;
4881 int_sstream << unsigned(data[i]);
4883 data_str.append(int_sstream.str());
4887 data_str.append(", ");
4891 data_str.append("]");
4898 /** @brief Iterate Compressed SubImage Test cases.
4900 * @return Iteration result.
4902 tcu::TestNode::IterateResult CompressedSubImageTest::iterate()
4904 /* Shortcut for GL functionality. */
4905 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4907 /* Get context setup. */
4908 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
4909 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
4911 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
4913 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
4918 /* Running tests. */
4920 bool is_error = false;
4924 is_ok &= Test<1>(GL_COMPRESSED_RGB);
4926 is_ok &= Test<2>(GL_COMPRESSED_RED_RGTC1);
4927 is_ok &= Test<2>(GL_COMPRESSED_SIGNED_RED_RGTC1);
4928 is_ok &= Test<2>(GL_COMPRESSED_RG_RGTC2);
4929 is_ok &= Test<2>(GL_COMPRESSED_SIGNED_RG_RGTC2);
4930 is_ok &= Test<2>(GL_COMPRESSED_RGBA_BPTC_UNORM);
4931 is_ok &= Test<2>(GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM);
4932 is_ok &= Test<2>(GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT);
4933 is_ok &= Test<2>(GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT);
4934 is_ok &= Test<2>(GL_COMPRESSED_RGB8_ETC2);
4935 is_ok &= Test<2>(GL_COMPRESSED_SRGB8_ETC2);
4936 is_ok &= Test<2>(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2);
4937 is_ok &= Test<2>(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2);
4938 is_ok &= Test<2>(GL_COMPRESSED_RGBA8_ETC2_EAC);
4939 is_ok &= Test<2>(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC);
4940 is_ok &= Test<2>(GL_COMPRESSED_R11_EAC);
4941 is_ok &= Test<2>(GL_COMPRESSED_SIGNED_R11_EAC);
4942 is_ok &= Test<2>(GL_COMPRESSED_RG11_EAC);
4943 is_ok &= Test<2>(GL_COMPRESSED_SIGNED_RG11_EAC);
4945 is_ok &= Test<3>(GL_COMPRESSED_RED_RGTC1);
4946 is_ok &= Test<3>(GL_COMPRESSED_SIGNED_RED_RGTC1);
4947 is_ok &= Test<3>(GL_COMPRESSED_RG_RGTC2);
4948 is_ok &= Test<3>(GL_COMPRESSED_SIGNED_RG_RGTC2);
4949 is_ok &= Test<3>(GL_COMPRESSED_RGBA_BPTC_UNORM);
4950 is_ok &= Test<3>(GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM);
4951 is_ok &= Test<3>(GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT);
4952 is_ok &= Test<3>(GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT);
4953 is_ok &= Test<3>(GL_COMPRESSED_RGB8_ETC2);
4954 is_ok &= Test<3>(GL_COMPRESSED_SRGB8_ETC2);
4955 is_ok &= Test<3>(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2);
4956 is_ok &= Test<3>(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2);
4957 is_ok &= Test<3>(GL_COMPRESSED_RGBA8_ETC2_EAC);
4958 is_ok &= Test<3>(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC);
4959 is_ok &= Test<3>(GL_COMPRESSED_R11_EAC);
4960 is_ok &= Test<3>(GL_COMPRESSED_SIGNED_R11_EAC);
4961 is_ok &= Test<3>(GL_COMPRESSED_RG11_EAC);
4962 is_ok &= Test<3>(GL_COMPRESSED_SIGNED_RG11_EAC);
4973 /* Errors clean up. */
4974 while (gl.getError())
4977 /* Result's setup. */
4980 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
4986 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
4990 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
4997 /** Reference data. */
4998 const glw::GLubyte CompressedSubImageTest::s_texture_data[] = {
4999 0x00, 0x00, 0x00, 0xFF, 0x7f, 0x7f, 0x7f, 0x00, 0xc3, 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0x00,
5000 0x88, 0x00, 0x15, 0xFF, 0xed, 0x1c, 0x24, 0x00, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x00, 0x00,
5001 0xc8, 0xbf, 0xe7, 0xFF, 0x70, 0x92, 0xbe, 0x00, 0x99, 0xd9, 0xea, 0xff, 0xb5, 0xe6, 0x1d, 0x00,
5002 0xa3, 0x49, 0xa4, 0xFF, 0x3f, 0x48, 0xcc, 0x00, 0x00, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0x00,
5004 0xa3, 0x49, 0xa4, 0xFF, 0xc8, 0xbf, 0xe7, 0x00, 0x88, 0x00, 0x15, 0xff, 0x00, 0x00, 0x00, 0x00,
5005 0x3f, 0x48, 0xcc, 0xFF, 0x70, 0x92, 0xbe, 0x00, 0xed, 0x1c, 0x24, 0xff, 0x7f, 0x7f, 0x7f, 0x00,
5006 0x00, 0xa2, 0xe8, 0xFF, 0x99, 0xd9, 0xea, 0x00, 0xff, 0x7f, 0x27, 0xff, 0xc3, 0xc3, 0xc3, 0x00,
5007 0x22, 0xb1, 0x4c, 0xFF, 0xb5, 0xe6, 0x1d, 0x00, 0xff, 0xf2, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00,
5009 0x22, 0xb1, 0x4c, 0xFF, 0x00, 0xa2, 0xe8, 0x00, 0x3f, 0x48, 0xcc, 0xff, 0xa3, 0x49, 0xa4, 0x00,
5010 0xb5, 0xe6, 0x1d, 0xFF, 0x99, 0xd9, 0xea, 0x00, 0x70, 0x92, 0xbe, 0xff, 0xc8, 0xbf, 0xe7, 0x00,
5011 0xff, 0xf2, 0x00, 0xFF, 0xff, 0x7f, 0x27, 0x00, 0xed, 0x1c, 0x24, 0xff, 0x88, 0x00, 0x15, 0x00,
5012 0xff, 0xff, 0xff, 0xFF, 0xc3, 0xc3, 0xc3, 0x00, 0x7f, 0x7f, 0x7f, 0xff, 0x00, 0x00, 0x00, 0x00,
5014 0xff, 0xff, 0xff, 0xFF, 0xff, 0xf2, 0x00, 0x00, 0xb5, 0xe6, 0x1d, 0xff, 0x22, 0xb1, 0x4c, 0x00,
5015 0xc3, 0xc3, 0xc3, 0xFF, 0xff, 0x7f, 0x27, 0x00, 0x99, 0xd9, 0xea, 0xff, 0x00, 0xa2, 0xe8, 0x00,
5016 0x7f, 0x7f, 0x7f, 0xFF, 0xed, 0x1c, 0x24, 0x00, 0x70, 0x92, 0xbe, 0xff, 0x3f, 0x48, 0xcc, 0x00,
5017 0x00, 0x00, 0x00, 0xFF, 0x88, 0x00, 0x15, 0x00, 0xc8, 0xbf, 0xe7, 0xff, 0xa3, 0x49, 0xa4, 0x00
5020 /** Reference data parameters. */
5021 const glw::GLuint CompressedSubImageTest::s_texture_width = 4;
5022 const glw::GLuint CompressedSubImageTest::s_texture_height = 4;
5023 const glw::GLuint CompressedSubImageTest::s_texture_depth = 4;
5024 const glw::GLuint CompressedSubImageTest::s_block_count = 8;
5025 const glw::GLuint CompressedSubImageTest::s_block_2d_size_x = 4;
5026 const glw::GLuint CompressedSubImageTest::s_block_2d_size_y = 2;
5027 const glw::GLuint CompressedSubImageTest::s_block_3d_size = 2;
5029 /******************************** Copy SubImage Test Implementation ********************************/
5031 /** @brief Compressed SubImage Test constructor.
5033 * @param [in] context OpenGL context.
5035 CopyTest::CopyTest(deqp::Context& context)
5036 : deqp::TestCase(context, "textures_copy", "Texture Copy Test")
5042 /* Intentionally left blank. */
5045 /** @brief Texture target selector.
5047 * @tparam D Texture dimenisons.
5049 * @return Texture target.
5052 glw::GLenum CopyTest::TextureTarget<1>()
5054 return GL_TEXTURE_1D;
5057 glw::GLenum CopyTest::TextureTarget<2>()
5059 return GL_TEXTURE_2D;
5062 glw::GLenum CopyTest::TextureTarget<3>()
5064 return GL_TEXTURE_3D;
5067 /** @brief Copy texture, check errors and log.
5069 * @note Parameters as passed to CopyTextureSubImage*D
5071 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
5073 bool CopyTest::CopyTextureSubImage1DAndCheckErrors(glw::GLuint texture, glw::GLint level, glw::GLint xoffset,
5074 glw::GLint x, glw::GLint y, glw::GLsizei width)
5076 /* Shortcut for GL functionality. */
5077 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5079 gl.readBuffer(GL_COLOR_ATTACHMENT0);
5080 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
5082 gl.copyTextureSubImage1D(texture, level, xoffset, x, y, width);
5087 if (GL_NO_ERROR != (error = gl.getError()))
5089 m_context.getTestContext().getLog() << tcu::TestLog::Message
5090 << "glCopyTextureSubImage1D unexpectedly generated error "
5091 << glu::getErrorStr(error) << ". Test fails." << tcu::TestLog::EndMessage;
5099 /** @brief Copy texture, check errors and log.
5101 * @note Parameters as passed to CopyTextureSubImage*D
5103 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
5105 bool CopyTest::CopyTextureSubImage2DAndCheckErrors(glw::GLuint texture, glw::GLint level, glw::GLint xoffset,
5106 glw::GLint yoffset, glw::GLint x, glw::GLint y, glw::GLsizei width,
5107 glw::GLsizei height)
5109 /* Shortcut for GL functionality. */
5110 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5112 gl.readBuffer(GL_COLOR_ATTACHMENT0);
5113 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
5115 gl.copyTextureSubImage2D(texture, level, xoffset, yoffset, x, y, width, height);
5120 if (GL_NO_ERROR != (error = gl.getError()))
5122 m_context.getTestContext().getLog() << tcu::TestLog::Message
5123 << "glCopyTextureSubImage2D unexpectedly generated error "
5124 << glu::getErrorStr(error) << ". Test fails." << tcu::TestLog::EndMessage;
5132 /** @brief Copy texture, check errors and log.
5134 * @note Parameters as passed to CopyTextureSubImage*D
5136 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
5138 bool CopyTest::CopyTextureSubImage3DAndCheckErrors(glw::GLuint texture, glw::GLint level, glw::GLint xoffset,
5139 glw::GLint yoffset, glw::GLint zoffset, glw::GLint x, glw::GLint y,
5140 glw::GLsizei width, glw::GLsizei height)
5142 /* Shortcut for GL functionality. */
5143 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5145 gl.readBuffer(GL_COLOR_ATTACHMENT0 + zoffset);
5146 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
5148 gl.copyTextureSubImage3D(texture, level, xoffset, yoffset, zoffset, x, y, width, height);
5153 if (GL_NO_ERROR != (error = gl.getError()))
5155 m_context.getTestContext().getLog() << tcu::TestLog::Message
5156 << "glCopyTextureSubImage3D unexpectedly generated error "
5157 << glu::getErrorStr(error) << ". Test fails." << tcu::TestLog::EndMessage;
5165 /** @brief Create texture.
5167 * @tparam D Dimmensions.
5170 void CopyTest::CreateSourceTexture<1>()
5172 /* Shortcut for GL functionality. */
5173 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5175 gl.genTextures(1, &m_to_src);
5176 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
5178 gl.bindTexture(TextureTarget<1>(), m_to_src);
5179 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
5181 gl.texImage1D(TextureTarget<1>(), 0, GL_RGBA8, s_texture_width, 0, GL_RGBA, GL_UNSIGNED_BYTE, s_texture_data);
5182 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D call failed.");
5185 /** @brief Create texture.
5187 * @tparam D Dimmensions.
5190 void CopyTest::CreateSourceTexture<2>()
5192 /* Shortcut for GL functionality. */
5193 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5195 gl.genTextures(1, &m_to_src);
5196 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
5198 gl.bindTexture(TextureTarget<2>(), m_to_src);
5199 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
5201 gl.texImage2D(TextureTarget<2>(), 0, GL_RGBA8, s_texture_width, s_texture_height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
5203 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D call failed.");
5206 /** @brief Create texture.
5208 * @tparam D Dimmensions.
5211 void CopyTest::CreateSourceTexture<3>()
5213 /* Shortcut for GL functionality. */
5214 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5216 gl.genTextures(1, &m_to_src);
5217 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
5219 gl.bindTexture(TextureTarget<3>(), m_to_src);
5220 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
5222 gl.texImage3D(TextureTarget<3>(), 0, GL_RGBA8, s_texture_width, s_texture_height, s_texture_depth, 0, GL_RGBA,
5223 GL_UNSIGNED_BYTE, s_texture_data);
5224 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D call failed.");
5227 /** @brief Create texture.
5229 * @tparam D Dimmensions.
5232 void CopyTest::CreateDestinationTexture<1>()
5234 /* Shortcut for GL functionality. */
5235 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5237 gl.genTextures(1, &m_to_dst);
5238 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
5240 gl.bindTexture(TextureTarget<1>(), m_to_dst);
5241 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
5243 gl.texImage1D(TextureTarget<1>(), 0, GL_RGBA8, s_texture_width, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL);
5244 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D call failed.");
5247 /** @brief Create texture.
5249 * @tparam D Dimmensions.
5252 void CopyTest::CreateDestinationTexture<2>()
5254 /* Shortcut for GL functionality. */
5255 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5257 gl.genTextures(1, &m_to_dst);
5258 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
5260 gl.bindTexture(TextureTarget<2>(), m_to_dst);
5261 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
5263 gl.texImage2D(TextureTarget<2>(), 0, GL_RGBA8, s_texture_width, s_texture_height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
5265 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D call failed.");
5268 /** @brief Create texture.
5270 * @tparam D Dimmensions.
5273 void CopyTest::CreateDestinationTexture<3>()
5275 /* Shortcut for GL functionality. */
5276 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5278 gl.genTextures(1, &m_to_dst);
5279 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
5281 gl.bindTexture(TextureTarget<3>(), m_to_dst);
5282 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
5284 gl.texImage3D(TextureTarget<3>(), 0, GL_RGBA8, s_texture_width, s_texture_height, s_texture_depth, 0, GL_RGBA,
5285 GL_UNSIGNED_BYTE, DE_NULL);
5286 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D call failed.");
5289 /** @brief Create framebuffer.
5291 * @tparam D Dimmensions.
5294 void CopyTest::CreateSourceFramebuffer<1>()
5296 /* Shortcut for GL functionality. */
5297 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5299 /* Prepare framebuffer. */
5300 gl.genFramebuffers(1, &m_fbo);
5301 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
5303 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
5304 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
5306 gl.framebufferTexture1D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, TextureTarget<1>(), m_to_src, 0);
5307 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferTexture1D call failed.");
5309 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
5314 gl.viewport(0, 0, s_texture_width, 1);
5315 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
5318 /** @brief Create framebuffer.
5320 * @tparam D Dimmensions.
5323 void CopyTest::CreateSourceFramebuffer<2>()
5325 /* Shortcut for GL functionality. */
5326 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5328 /* Prepare framebuffer. */
5329 gl.genFramebuffers(1, &m_fbo);
5330 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
5332 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
5333 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
5335 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, TextureTarget<2>(), m_to_src, 0);
5336 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferTexture1D call failed.");
5338 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
5343 gl.viewport(0, 0, s_texture_width, s_texture_height);
5344 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
5347 /** @brief Create framebuffer.
5349 * @tparam D Dimmensions.
5352 void CopyTest::CreateSourceFramebuffer<3>()
5354 /* Shortcut for GL functionality. */
5355 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5357 /* Prepare framebuffer. */
5358 gl.genFramebuffers(1, &m_fbo);
5359 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
5361 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
5362 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
5364 for (glw::GLuint i = 0; i < s_texture_depth; ++i)
5366 gl.framebufferTexture3D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, TextureTarget<3>(), m_to_src, 0, i);
5367 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferTexture1D call failed.");
5370 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
5375 gl.viewport(0, 0, s_texture_width, s_texture_height);
5376 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
5379 /** @brief Dispatch function to create test objects */
5380 template <glw::GLuint D>
5381 void CopyTest::CreateAll()
5383 CreateSourceTexture<D>();
5384 CreateSourceFramebuffer<D>();
5385 CreateDestinationTexture<D>();
5388 /** @brief Test function */
5390 bool CopyTest::Test<1>()
5396 result &= CopyTextureSubImage1DAndCheckErrors(m_to_dst, 0, 0, 0, 0, s_texture_width / 2);
5397 result &= CopyTextureSubImage1DAndCheckErrors(m_to_dst, 0, s_texture_width / 2, s_texture_width / 2, 0,
5398 s_texture_width / 2);
5400 result &= CheckData(TextureTarget<1>(), 4 /* RGBA */ * s_texture_width);
5407 /** @brief Test function */
5409 bool CopyTest::Test<2>()
5415 result &= CopyTextureSubImage2DAndCheckErrors(m_to_dst, 0, 0, 0, 0, 0, s_texture_width / 2, s_texture_height / 2);
5416 result &= CopyTextureSubImage2DAndCheckErrors(m_to_dst, 0, s_texture_width / 2, 0, s_texture_width / 2, 0,
5417 s_texture_width / 2, s_texture_height / 2);
5418 result &= CopyTextureSubImage2DAndCheckErrors(m_to_dst, 0, 0, s_texture_height / 2, 0, s_texture_height / 2,
5419 s_texture_width / 2, s_texture_height / 2);
5421 CopyTextureSubImage2DAndCheckErrors(m_to_dst, 0, s_texture_width / 2, s_texture_height / 2, s_texture_width / 2,
5422 s_texture_height / 2, s_texture_width / 2, s_texture_height / 2);
5424 result &= CheckData(TextureTarget<2>(), 4 /* RGBA */ * s_texture_width * s_texture_height);
5431 /** @brief Test function */
5433 bool CopyTest::Test<3>()
5439 for (glw::GLuint i = 0; i < s_texture_depth; ++i)
5442 CopyTextureSubImage3DAndCheckErrors(m_to_dst, 0, 0, 0, i, 0, 0, s_texture_width / 2, s_texture_height / 2);
5443 result &= CopyTextureSubImage3DAndCheckErrors(m_to_dst, 0, s_texture_width / 2, 0, i, s_texture_width / 2, 0,
5444 s_texture_width / 2, s_texture_height / 2);
5445 result &= CopyTextureSubImage3DAndCheckErrors(m_to_dst, 0, 0, s_texture_height / 2, i, 0, s_texture_height / 2,
5446 s_texture_width / 2, s_texture_height / 2);
5447 result &= CopyTextureSubImage3DAndCheckErrors(m_to_dst, 0, s_texture_width / 2, s_texture_height / 2, i,
5448 s_texture_width / 2, s_texture_height / 2, s_texture_width / 2,
5449 s_texture_height / 2);
5452 result &= CheckData(TextureTarget<3>(), 4 /* RGBA */ * s_texture_width * s_texture_height * s_texture_depth);
5459 /** @brief Compre results with the reference.
5461 * @param [in] target Texture target.
5462 * @param [in] size Size of the buffer.
5464 * @return True if equal, false otherwise.
5466 bool CopyTest::CheckData(glw::GLenum target, glw::GLuint size)
5468 /* Shortcut for GL functionality. */
5469 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5471 /* Check texture content with reference. */
5472 m_result = new glw::GLubyte[size];
5474 if (DE_NULL == m_result)
5479 gl.getTexImage(target, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_result);
5480 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
5482 for (glw::GLuint i = 0; i < size; ++i)
5484 if (s_texture_data[i] != m_result[i])
5486 m_context.getTestContext().getLog()
5487 << tcu::TestLog::Message << "glCopyTextureSubImage*D created texture with data "
5488 << DataToString(size, s_texture_data) << " however texture contains data "
5489 << DataToString(size, m_result) << ". Texture target was " << glu::getTextureTargetStr(target)
5490 << ". Test fails." << tcu::TestLog::EndMessage;
5499 /** @brief Convert raw data into string for logging purposes.
5501 * @param [in] count Count of the data.
5502 * @param [in] data Raw data.
5504 * @return String representation of data.
5506 std::string CopyTest::DataToString(glw::GLuint count, const glw::GLubyte data[])
5508 std::string data_str = "[";
5510 for (glw::GLuint i = 0; i < count; ++i)
5512 std::stringstream int_sstream;
5514 int_sstream << unsigned(data[i]);
5516 data_str.append(int_sstream.str());
5520 data_str.append(", ");
5524 data_str.append("]");
5531 /** @brief Clean GL objects, test variables and GL errors.
5533 void CopyTest::CleanAll()
5535 /* Shortcut for GL functionality. */
5536 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5540 gl.deleteFramebuffers(1, &m_fbo);
5547 gl.deleteTextures(1, &m_to_src);
5554 gl.deleteTextures(1, &m_to_dst);
5559 if (DE_NULL == m_result)
5566 while (GL_NO_ERROR != gl.getError())
5570 /** @brief Iterate Copy Test cases.
5572 * @return Iteration result.
5574 tcu::TestNode::IterateResult CopyTest::iterate()
5576 /* Get context setup. */
5577 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
5578 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
5580 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
5582 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
5587 /* Running tests. */
5589 bool is_error = false;
5606 /* Result's setup. */
5609 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
5615 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
5619 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
5626 /** Reference data. */
5627 const glw::GLubyte CopyTest::s_texture_data[] = {
5628 0x00, 0x00, 0x00, 0xFF, 0x7f, 0x7f, 0x7f, 0x00, 0xc3, 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0x00,
5629 0x88, 0x00, 0x15, 0xFF, 0xed, 0x1c, 0x24, 0x00, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x00, 0x00,
5630 0xc8, 0xbf, 0xe7, 0xFF, 0x70, 0x92, 0xbe, 0x00, 0x99, 0xd9, 0xea, 0xff, 0xb5, 0xe6, 0x1d, 0x00,
5631 0xa3, 0x49, 0xa4, 0xFF, 0x3f, 0x48, 0xcc, 0x00, 0x00, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0x00,
5633 0xa3, 0x49, 0xa4, 0xFF, 0xc8, 0xbf, 0xe7, 0x00, 0x88, 0x00, 0x15, 0xff, 0x00, 0x00, 0x00, 0x00,
5634 0x3f, 0x48, 0xcc, 0xFF, 0x70, 0x92, 0xbe, 0x00, 0xed, 0x1c, 0x24, 0xff, 0x7f, 0x7f, 0x7f, 0x00,
5635 0x00, 0xa2, 0xe8, 0xFF, 0x99, 0xd9, 0xea, 0x00, 0xff, 0x7f, 0x27, 0xff, 0xc3, 0xc3, 0xc3, 0x00,
5636 0x22, 0xb1, 0x4c, 0xFF, 0xb5, 0xe6, 0x1d, 0x00, 0xff, 0xf2, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00,
5638 0x22, 0xb1, 0x4c, 0xFF, 0x00, 0xa2, 0xe8, 0x00, 0x3f, 0x48, 0xcc, 0xff, 0xa3, 0x49, 0xa4, 0x00,
5639 0xb5, 0xe6, 0x1d, 0xFF, 0x99, 0xd9, 0xea, 0x00, 0x70, 0x92, 0xbe, 0xff, 0xc8, 0xbf, 0xe7, 0x00,
5640 0xff, 0xf2, 0x00, 0xFF, 0xff, 0x7f, 0x27, 0x00, 0xed, 0x1c, 0x24, 0xff, 0x88, 0x00, 0x15, 0x00,
5641 0xff, 0xff, 0xff, 0xFF, 0xc3, 0xc3, 0xc3, 0x00, 0x7f, 0x7f, 0x7f, 0xff, 0x00, 0x00, 0x00, 0x00,
5643 0xff, 0xff, 0xff, 0xFF, 0xff, 0xf2, 0x00, 0x00, 0xb5, 0xe6, 0x1d, 0xff, 0x22, 0xb1, 0x4c, 0x00,
5644 0xc3, 0xc3, 0xc3, 0xFF, 0xff, 0x7f, 0x27, 0x00, 0x99, 0xd9, 0xea, 0xff, 0x00, 0xa2, 0xe8, 0x00,
5645 0x7f, 0x7f, 0x7f, 0xFF, 0xed, 0x1c, 0x24, 0x00, 0x70, 0x92, 0xbe, 0xff, 0x3f, 0x48, 0xcc, 0x00,
5646 0x00, 0x00, 0x00, 0xFF, 0x88, 0x00, 0x15, 0x00, 0xc8, 0xbf, 0xe7, 0xff, 0xa3, 0x49, 0xa4, 0x00
5649 /** Reference data parameters. */
5650 const glw::GLuint CopyTest::s_texture_width = 4;
5651 const glw::GLuint CopyTest::s_texture_height = 4;
5652 const glw::GLuint CopyTest::s_texture_depth = 4;
5654 /******************************** Get Set Parameter Test Implementation ********************************/
5656 /** @brief Get Set Parameter Test constructor.
5658 * @param [in] context OpenGL context.
5660 GetSetParameterTest::GetSetParameterTest(deqp::Context& context)
5661 : deqp::TestCase(context, "textures_get_set_parameter", "Texture Get Set Parameter Test")
5663 /* Intentionally left blank. */
5666 /** @brief Iterate Get Set Parameter Test cases.
5668 * @return Iteration result.
5670 tcu::TestNode::IterateResult GetSetParameterTest::iterate()
5672 /* Shortcut for GL functionality. */
5673 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5675 /* Get context setup. */
5676 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
5677 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
5679 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
5681 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
5686 /* Running tests. */
5688 bool is_error = false;
5691 glw::GLuint texture = 0;
5695 gl.genTextures(1, &texture);
5696 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
5698 gl.bindTexture(GL_TEXTURE_3D, texture);
5699 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
5702 glw::GLenum name = GL_DEPTH_STENCIL_TEXTURE_MODE;
5703 glw::GLint value_src = GL_DEPTH_COMPONENT;
5704 glw::GLint value_dst = 0;
5706 gl.textureParameteri(texture, name, value_src);
5707 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
5709 gl.getTextureParameteriv(texture, name, &value_dst);
5710 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
5712 is_ok &= CompareAndLog(value_src, value_dst, name);
5716 glw::GLenum name = GL_TEXTURE_BASE_LEVEL;
5717 glw::GLint value_src = 2;
5718 glw::GLint value_dst = 0;
5720 gl.textureParameteri(texture, name, value_src);
5721 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
5723 gl.getTextureParameteriv(texture, name, &value_dst);
5724 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
5726 is_ok &= CompareAndLog(value_src, value_dst, name);
5730 glw::GLenum name = GL_TEXTURE_BORDER_COLOR;
5731 glw::GLfloat value_src[4] = { 0.25, 0.5, 0.75, 1.0 };
5732 glw::GLfloat value_dst[4] = {};
5734 gl.textureParameterfv(texture, name, value_src);
5735 is_ok &= CheckErrorAndLog("glTextureParameterfv", name);
5737 gl.getTextureParameterfv(texture, name, value_dst);
5738 is_ok &= CheckErrorAndLog("glGetTextureParameterfv", name);
5740 is_ok &= CompareAndLog(value_src, value_dst, name);
5744 glw::GLenum name = GL_TEXTURE_BORDER_COLOR;
5745 glw::GLint value_src[4] = { 0, 64, -64, -32 };
5746 glw::GLint value_dst[4] = {};
5748 gl.textureParameterIiv(texture, name, value_src);
5749 is_ok &= CheckErrorAndLog("glTextureParameterIiv", name);
5751 gl.getTextureParameterIiv(texture, name, value_dst);
5752 is_ok &= CheckErrorAndLog("glGetTextureParameterIiv", name);
5754 is_ok &= CompareAndLog(value_src, value_dst, name);
5758 glw::GLenum name = GL_TEXTURE_BORDER_COLOR;
5759 glw::GLuint value_src[4] = { 0, 64, 128, 192 };
5760 glw::GLuint value_dst[4] = {};
5762 gl.textureParameterIuiv(texture, name, value_src);
5763 is_ok &= CheckErrorAndLog("glTextureParameterIuiv", name);
5765 gl.getTextureParameterIuiv(texture, name, value_dst);
5766 is_ok &= CheckErrorAndLog("glGetTextureParameterIuiv", name);
5768 is_ok &= CompareAndLog(value_src, value_dst, name);
5772 glw::GLenum name = GL_TEXTURE_COMPARE_FUNC;
5773 glw::GLint value_src = GL_LEQUAL;
5774 glw::GLint value_dst = 0;
5776 gl.textureParameteri(texture, name, value_src);
5777 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
5779 gl.getTextureParameteriv(texture, name, &value_dst);
5780 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
5782 is_ok &= CompareAndLog(value_src, value_dst, name);
5786 glw::GLenum name = GL_TEXTURE_COMPARE_MODE;
5787 glw::GLint value_src = GL_COMPARE_REF_TO_TEXTURE;
5788 glw::GLint value_dst = 0;
5790 gl.textureParameteri(texture, name, value_src);
5791 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
5793 gl.getTextureParameteriv(texture, name, &value_dst);
5794 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
5796 is_ok &= CompareAndLog(value_src, value_dst, name);
5800 glw::GLenum name = GL_TEXTURE_LOD_BIAS;
5801 glw::GLfloat value_src = -2.f;
5802 glw::GLfloat value_dst = 0.f;
5804 gl.textureParameterf(texture, name, value_src);
5805 is_ok &= CheckErrorAndLog("glTextureParameterf", name);
5807 gl.getTextureParameterfv(texture, name, &value_dst);
5808 is_ok &= CheckErrorAndLog("glGetTextureParameterfv", name);
5810 is_ok &= CompareAndLog(value_src, value_dst, name);
5814 glw::GLenum name = GL_TEXTURE_MIN_FILTER;
5815 glw::GLint value_src = GL_LINEAR_MIPMAP_NEAREST;
5816 glw::GLint value_dst = 0;
5818 gl.textureParameteri(texture, name, value_src);
5819 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
5821 gl.getTextureParameteriv(texture, name, &value_dst);
5822 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
5824 is_ok &= CompareAndLog(value_src, value_dst, name);
5828 glw::GLenum name = GL_TEXTURE_MAG_FILTER;
5829 glw::GLint value_src = GL_NEAREST;
5830 glw::GLint value_dst = 0;
5832 gl.textureParameteri(texture, name, value_src);
5833 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
5835 gl.getTextureParameteriv(texture, name, &value_dst);
5836 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
5838 is_ok &= CompareAndLog(value_src, value_dst, name);
5842 glw::GLenum name = GL_TEXTURE_MIN_LOD;
5843 glw::GLint value_src = -100;
5844 glw::GLint value_dst = 0;
5846 gl.textureParameteri(texture, name, value_src);
5847 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
5849 gl.getTextureParameteriv(texture, name, &value_dst);
5850 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
5852 is_ok &= CompareAndLog(value_src, value_dst, name);
5856 glw::GLenum name = GL_TEXTURE_MAX_LOD;
5857 glw::GLint value_src = 100;
5858 glw::GLint value_dst = 0;
5860 gl.textureParameteri(texture, name, value_src);
5861 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
5863 gl.getTextureParameteriv(texture, name, &value_dst);
5864 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
5866 is_ok &= CompareAndLog(value_src, value_dst, name);
5870 glw::GLenum name = GL_TEXTURE_MAX_LEVEL;
5871 glw::GLint value_src = 100;
5872 glw::GLint value_dst = 0;
5874 gl.textureParameteri(texture, name, value_src);
5875 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
5877 gl.getTextureParameteriv(texture, name, &value_dst);
5878 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
5880 is_ok &= CompareAndLog(value_src, value_dst, name);
5884 glw::GLenum name = GL_TEXTURE_SWIZZLE_R;
5885 glw::GLint value_src = GL_BLUE;
5886 glw::GLint value_dst = 0;
5888 gl.textureParameteri(texture, name, value_src);
5889 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
5891 gl.getTextureParameteriv(texture, name, &value_dst);
5892 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
5894 is_ok &= CompareAndLog(value_src, value_dst, name);
5898 glw::GLenum name = GL_TEXTURE_SWIZZLE_G;
5899 glw::GLint value_src = GL_ALPHA;
5900 glw::GLint value_dst = 0;
5902 gl.textureParameteri(texture, name, value_src);
5903 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
5905 gl.getTextureParameteriv(texture, name, &value_dst);
5906 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
5908 is_ok &= CompareAndLog(value_src, value_dst, name);
5912 glw::GLenum name = GL_TEXTURE_SWIZZLE_B;
5913 glw::GLint value_src = GL_RED;
5914 glw::GLint value_dst = 0;
5916 gl.textureParameteri(texture, name, value_src);
5917 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
5919 gl.getTextureParameteriv(texture, name, &value_dst);
5920 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
5922 is_ok &= CompareAndLog(value_src, value_dst, name);
5926 glw::GLenum name = GL_TEXTURE_SWIZZLE_A;
5927 glw::GLint value_src = GL_GREEN;
5928 glw::GLint value_dst = 0;
5930 gl.textureParameteri(texture, name, value_src);
5931 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
5933 gl.getTextureParameteriv(texture, name, &value_dst);
5934 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
5936 is_ok &= CompareAndLog(value_src, value_dst, name);
5940 glw::GLenum name = GL_TEXTURE_SWIZZLE_RGBA;
5941 glw::GLint value_src[4] = { GL_ZERO, GL_ONE, GL_ZERO, GL_ONE };
5942 glw::GLint value_dst[4] = {};
5944 gl.textureParameteriv(texture, name, value_src);
5945 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
5947 gl.getTextureParameteriv(texture, name, value_dst);
5948 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
5950 is_ok &= CompareAndLog(value_src, value_dst, name);
5954 glw::GLenum name = GL_TEXTURE_WRAP_S;
5955 glw::GLint value_src = GL_MIRROR_CLAMP_TO_EDGE;
5956 glw::GLint value_dst = 11;
5958 gl.textureParameteri(texture, name, value_src);
5959 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
5961 gl.getTextureParameteriv(texture, name, &value_dst);
5962 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
5964 is_ok &= CompareAndLog(value_src, value_dst, name);
5968 glw::GLenum name = GL_TEXTURE_WRAP_T;
5969 glw::GLint value_src = GL_CLAMP_TO_EDGE;
5970 glw::GLint value_dst = 11;
5972 gl.textureParameteri(texture, name, value_src);
5973 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
5975 gl.getTextureParameteriv(texture, name, &value_dst);
5976 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
5978 is_ok &= CompareAndLog(value_src, value_dst, name);
5982 glw::GLenum name = GL_TEXTURE_WRAP_R;
5983 glw::GLint value_src = GL_CLAMP_TO_EDGE;
5984 glw::GLint value_dst = 11;
5986 gl.textureParameteriv(texture, name, &value_src);
5987 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
5989 gl.getTextureParameteriv(texture, name, &value_dst);
5990 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
5992 is_ok &= CompareAndLog(value_src, value_dst, name);
6004 gl.deleteTextures(1, &texture);
6007 while (GL_NO_ERROR != gl.getError())
6010 /* Result's setup. */
6013 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
6019 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
6023 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
6030 /** @brief Check for errors and log.
6032 * @param [in] fname Name of the function (to be logged).
6033 * @param [in] pname Parameter name with which function was called.
6035 * @return True if no error, false otherwise.
6037 bool GetSetParameterTest::CheckErrorAndLog(const glw::GLchar* fname, glw::GLenum pname)
6039 /* Shortcut for GL functionality. */
6040 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
6045 if (GL_NO_ERROR != (error = gl.getError()))
6047 m_context.getTestContext().getLog() << tcu::TestLog::Message << fname << " unexpectedly generated error "
6048 << glu::getErrorStr(error) << " during test of pname "
6049 << glu::getTextureParameterStr(pname) << ". Test fails."
6050 << tcu::TestLog::EndMessage;
6058 /** @brief Compare queried value of parameter with the expected vale.
6060 * @param [in] value_src First value.
6061 * @param [in] value_dst Second value.
6062 * @param [in] pname Parameter name.
6064 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6066 bool GetSetParameterTest::CompareAndLog(glw::GLint value_src, glw::GLint value_dst, glw::GLenum pname)
6068 if (value_src != value_dst)
6070 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Queried value of pname "
6071 << glu::getTextureParameterStr(pname) << " is equal to " << value_dst
6072 << ", however " << value_src << " was expected. Test fails."
6073 << tcu::TestLog::EndMessage;
6081 /** @brief Compare queried value of parameter with the expected vale.
6083 * @param [in] value_src First value.
6084 * @param [in] value_dst Second value.
6085 * @param [in] pname Parameter name.
6087 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6089 bool GetSetParameterTest::CompareAndLog(glw::GLuint value_src, glw::GLuint value_dst, glw::GLenum pname)
6091 if (value_src != value_dst)
6093 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Queried value of pname "
6094 << glu::getTextureParameterStr(pname) << " is equal to " << value_dst
6095 << ", however " << value_src << " was expected. Test fails."
6096 << tcu::TestLog::EndMessage;
6104 /** @brief Compare queried value of parameter with the expected vale.
6106 * @param [in] value_src First value.
6107 * @param [in] value_dst Second value.
6108 * @param [in] pname Parameter name.
6110 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6112 bool GetSetParameterTest::CompareAndLog(glw::GLfloat value_src, glw::GLfloat value_dst, glw::GLenum pname)
6114 if (de::abs(value_src - value_dst) > 0.0125 /* Precision */)
6116 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Queried value of pname "
6117 << glu::getTextureParameterStr(pname) << " is equal to " << value_dst
6118 << ", however " << value_src << " was expected. Test fails."
6119 << tcu::TestLog::EndMessage;
6127 /** @brief Compare queried value of parameter with the expected vale.
6129 * @param [in] value_src First value.
6130 * @param [in] value_dst Second value.
6131 * @param [in] pname Parameter name.
6133 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6135 bool GetSetParameterTest::CompareAndLog(glw::GLint value_src[4], glw::GLint value_dst[4], glw::GLenum pname)
6137 if ((value_src[0] != value_dst[0]) || (value_src[1] != value_dst[1]) || (value_src[2] != value_dst[2]) ||
6138 (value_src[3] != value_dst[3]))
6140 m_context.getTestContext().getLog()
6141 << tcu::TestLog::Message << "Queried value of pname " << glu::getTextureParameterStr(pname)
6142 << " is equal to [" << value_dst[0] << ", " << value_dst[1] << ", " << value_dst[2] << ", " << value_dst[3]
6143 << "], however " << value_src[0] << ", " << value_src[1] << ", " << value_src[2] << ", " << value_src[3]
6144 << "] was expected. Test fails." << tcu::TestLog::EndMessage;
6152 /** @brief Compare queried value of parameter with the expected vale.
6154 * @param [in] value_src First value.
6155 * @param [in] value_dst Second value.
6156 * @param [in] pname Parameter name.
6158 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6160 bool GetSetParameterTest::CompareAndLog(glw::GLuint value_src[4], glw::GLuint value_dst[4], glw::GLenum pname)
6162 if ((value_src[0] != value_dst[0]) || (value_src[1] != value_dst[1]) || (value_src[2] != value_dst[2]) ||
6163 (value_src[3] != value_dst[3]))
6165 m_context.getTestContext().getLog()
6166 << tcu::TestLog::Message << "Queried value of pname " << glu::getTextureParameterStr(pname)
6167 << " is equal to [" << value_dst[0] << ", " << value_dst[1] << ", " << value_dst[2] << ", " << value_dst[3]
6168 << "], however " << value_src[0] << ", " << value_src[1] << ", " << value_src[2] << ", " << value_src[3]
6169 << "] was expected. Test fails." << tcu::TestLog::EndMessage;
6177 /** @brief Compare queried value of parameter with the expected vale.
6179 * @param [in] value_src First value.
6180 * @param [in] value_dst Second value.
6181 * @param [in] pname Parameter name.
6183 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6185 bool GetSetParameterTest::CompareAndLog(glw::GLfloat value_src[4], glw::GLfloat value_dst[4], glw::GLenum pname)
6187 if ((de::abs(value_src[0] - value_dst[0]) > 0.0125 /* Precision */) ||
6188 (de::abs(value_src[1] - value_dst[1]) > 0.0125 /* Precision */) ||
6189 (de::abs(value_src[2] - value_dst[2]) > 0.0125 /* Precision */) ||
6190 (de::abs(value_src[3] - value_dst[3]) > 0.0125 /* Precision */))
6192 m_context.getTestContext().getLog()
6193 << tcu::TestLog::Message << "Queried value of pname " << glu::getTextureParameterStr(pname)
6194 << " is equal to [" << value_dst[0] << ", " << value_dst[1] << ", " << value_dst[2] << ", " << value_dst[3]
6195 << "], however " << value_src[0] << ", " << value_src[1] << ", " << value_src[2] << ", " << value_src[3]
6196 << "] was expected. Test fails." << tcu::TestLog::EndMessage;
6204 /******************************** Defaults Test Implementation ********************************/
6206 /** @brief Defaults Test constructor.
6208 * @param [in] context OpenGL context.
6210 DefaultsTest::DefaultsTest(deqp::Context& context)
6211 : deqp::TestCase(context, "textures_defaults", "Texture Defaults Test")
6213 /* Intentionally left blank. */
6216 /** @brief Defaults Test cases.
6218 * @return Iteration result.
6220 tcu::TestNode::IterateResult DefaultsTest::iterate()
6222 /* Shortcut for GL functionality. */
6223 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
6225 /* Get context setup. */
6226 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
6227 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
6229 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
6231 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
6236 /* Running tests. */
6238 bool is_error = false;
6241 glw::GLuint texture = 0;
6245 gl.createTextures(GL_TEXTURE_3D, 1, &texture);
6246 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
6249 glw::GLenum name = GL_DEPTH_STENCIL_TEXTURE_MODE;
6250 glw::GLint value_ref = GL_DEPTH_COMPONENT;
6251 glw::GLint value_dst = 0;
6253 gl.getTextureParameteriv(texture, name, &value_dst);
6254 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6256 is_ok &= CompareAndLog(value_ref, value_dst, name);
6260 glw::GLenum name = GL_TEXTURE_BASE_LEVEL;
6261 glw::GLint value_ref = 0;
6262 glw::GLint value_dst = 1;
6264 gl.getTextureParameteriv(texture, name, &value_dst);
6265 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6267 is_ok &= CompareAndLog(value_ref, value_dst, name);
6271 glw::GLenum name = GL_TEXTURE_BORDER_COLOR;
6272 glw::GLfloat value_ref[4] = { 0.f, 0.f, 0.f, 0.f };
6273 glw::GLfloat value_dst[4] = {};
6275 gl.getTextureParameterfv(texture, name, value_dst);
6276 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6278 is_ok &= CompareAndLog(value_ref, value_dst, name);
6282 glw::GLenum name = GL_TEXTURE_COMPARE_FUNC;
6283 glw::GLint value_ref = GL_LEQUAL;
6284 glw::GLint value_dst = 0;
6286 gl.getTextureParameteriv(texture, name, &value_dst);
6287 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6289 is_ok &= CompareAndLog(value_ref, value_dst, name);
6293 glw::GLenum name = GL_TEXTURE_COMPARE_MODE;
6294 glw::GLint value_ref = GL_NONE;
6295 glw::GLint value_dst = 0;
6297 gl.getTextureParameteriv(texture, name, &value_dst);
6298 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6300 is_ok &= CompareAndLog(value_ref, value_dst, name);
6304 glw::GLenum name = GL_TEXTURE_LOD_BIAS;
6305 glw::GLfloat value_ref = 0.f;
6306 glw::GLfloat value_dst = 0.f;
6308 gl.getTextureParameterfv(texture, name, &value_dst);
6309 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6311 is_ok &= CompareAndLog(value_ref, value_dst, name);
6315 glw::GLenum name = GL_TEXTURE_MIN_FILTER;
6316 glw::GLint value_ref = GL_NEAREST_MIPMAP_LINEAR;
6317 glw::GLint value_dst = 0;
6319 gl.getTextureParameteriv(texture, name, &value_dst);
6320 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6322 is_ok &= CompareAndLog(value_ref, value_dst, name);
6326 glw::GLenum name = GL_TEXTURE_MAG_FILTER;
6327 glw::GLint value_ref = GL_LINEAR;
6328 glw::GLint value_dst = 0;
6330 gl.getTextureParameteriv(texture, name, &value_dst);
6331 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6333 is_ok &= CompareAndLog(value_ref, value_dst, name);
6337 glw::GLenum name = GL_TEXTURE_MIN_LOD;
6338 glw::GLint value_ref = -1000;
6339 glw::GLint value_dst = 0;
6341 gl.getTextureParameteriv(texture, name, &value_dst);
6342 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6344 is_ok &= CompareAndLog(value_ref, value_dst, name);
6348 glw::GLenum name = GL_TEXTURE_MAX_LOD;
6349 glw::GLint value_ref = 1000;
6350 glw::GLint value_dst = 0;
6352 gl.getTextureParameteriv(texture, name, &value_dst);
6353 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6355 is_ok &= CompareAndLog(value_ref, value_dst, name);
6359 glw::GLenum name = GL_TEXTURE_MAX_LEVEL;
6360 glw::GLint value_ref = 1000;
6361 glw::GLint value_dst = 0;
6363 gl.getTextureParameteriv(texture, name, &value_dst);
6364 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6366 is_ok &= CompareAndLog(value_ref, value_dst, name);
6370 glw::GLenum name = GL_TEXTURE_SWIZZLE_R;
6371 glw::GLint value_ref = GL_RED;
6372 glw::GLint value_dst = 0;
6374 gl.getTextureParameteriv(texture, name, &value_dst);
6375 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6377 is_ok &= CompareAndLog(value_ref, value_dst, name);
6381 glw::GLenum name = GL_TEXTURE_SWIZZLE_G;
6382 glw::GLint value_ref = GL_GREEN;
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_SWIZZLE_B;
6393 glw::GLint value_ref = GL_BLUE;
6394 glw::GLint value_dst = 0;
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_SWIZZLE_A;
6404 glw::GLint value_ref = GL_ALPHA;
6405 glw::GLint value_dst = 0;
6407 gl.getTextureParameteriv(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_WRAP_S;
6415 glw::GLint value_ref = GL_REPEAT;
6416 glw::GLint value_dst = 11;
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_WRAP_T;
6426 glw::GLint value_ref = GL_REPEAT;
6427 glw::GLint value_dst = 11;
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_WRAP_R;
6437 glw::GLint value_ref = GL_REPEAT;
6438 glw::GLint value_dst = 11;
6440 gl.getTextureParameteriv(texture, name, &value_dst);
6441 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6443 is_ok &= CompareAndLog(value_ref, value_dst, name);
6455 gl.deleteTextures(1, &texture);
6458 while (GL_NO_ERROR != gl.getError())
6461 /* Result's setup. */
6464 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
6470 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
6474 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
6481 /** @brief Compare queried value of parameter with the expected vale.
6483 * @param [in] value_src First value.
6484 * @param [in] value_dst Second value.
6485 * @param [in] pname Parameter name.
6487 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6489 bool DefaultsTest::CompareAndLog(glw::GLint value_ref, glw::GLint value_dst, glw::GLenum pname)
6491 if (value_ref != value_dst)
6493 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Queried value of pname "
6494 << glu::getTextureParameterStr(pname) << " is equal to " << value_dst
6495 << ", however " << value_ref << " was expected. Test fails."
6496 << tcu::TestLog::EndMessage;
6504 /** @brief Compare queried value of parameter with the expected vale.
6506 * @param [in] value_src First value.
6507 * @param [in] value_dst Second value.
6508 * @param [in] pname Parameter name.
6510 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6512 bool DefaultsTest::CompareAndLog(glw::GLuint value_ref, glw::GLuint value_dst, glw::GLenum pname)
6514 if (value_ref != value_dst)
6516 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Queried value of pname "
6517 << glu::getTextureParameterStr(pname) << " is equal to " << value_dst
6518 << ", however " << value_ref << " was expected. Test fails."
6519 << tcu::TestLog::EndMessage;
6527 /** @brief Compare queried value of parameter with the expected vale.
6529 * @param [in] value_src First value.
6530 * @param [in] value_dst Second value.
6531 * @param [in] pname Parameter name.
6533 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6535 bool DefaultsTest::CompareAndLog(glw::GLfloat value_ref, glw::GLfloat value_dst, glw::GLenum pname)
6537 if (de::abs(value_ref - value_dst) > 0.0125 /* Precision */)
6539 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Queried value of pname "
6540 << glu::getTextureParameterStr(pname) << " is equal to " << value_dst
6541 << ", however " << value_ref << " was expected. Test fails."
6542 << tcu::TestLog::EndMessage;
6550 /** @brief Compare queried value of parameter with the expected vale.
6552 * @param [in] value_src First value.
6553 * @param [in] value_dst Second value.
6554 * @param [in] pname Parameter name.
6556 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6558 bool DefaultsTest::CompareAndLog(glw::GLint value_ref[4], glw::GLint value_dst[4], glw::GLenum pname)
6560 if ((value_ref[0] != value_dst[0]) || (value_ref[1] != value_dst[1]) || (value_ref[2] != value_dst[2]) ||
6561 (value_ref[3] != value_dst[3]))
6563 m_context.getTestContext().getLog()
6564 << tcu::TestLog::Message << "Queried value of pname " << glu::getTextureParameterStr(pname)
6565 << " is equal to [" << value_dst[0] << ", " << value_dst[1] << ", " << value_dst[2] << ", " << value_dst[3]
6566 << "], however " << value_ref[0] << ", " << value_ref[1] << ", " << value_ref[2] << ", " << value_ref[3]
6567 << "] was expected. Test fails." << tcu::TestLog::EndMessage;
6575 /** @brief Compare queried value of parameter with the expected vale.
6577 * @param [in] value_src First value.
6578 * @param [in] value_dst Second value.
6579 * @param [in] pname Parameter name.
6581 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6583 bool DefaultsTest::CompareAndLog(glw::GLuint value_ref[4], glw::GLuint value_dst[4], glw::GLenum pname)
6585 if ((value_ref[0] != value_dst[0]) || (value_ref[1] != value_dst[1]) || (value_ref[2] != value_dst[2]) ||
6586 (value_ref[3] != value_dst[3]))
6588 m_context.getTestContext().getLog()
6589 << tcu::TestLog::Message << "Queried value of pname " << glu::getTextureParameterStr(pname)
6590 << " is equal to [" << value_dst[0] << ", " << value_dst[1] << ", " << value_dst[2] << ", " << value_dst[3]
6591 << "], however " << value_ref[0] << ", " << value_ref[1] << ", " << value_ref[2] << ", " << value_ref[3]
6592 << "] was expected. Test fails." << tcu::TestLog::EndMessage;
6600 /** @brief Compare queried value of parameter with the expected vale.
6602 * @param [in] value_src First value.
6603 * @param [in] value_dst Second value.
6604 * @param [in] pname Parameter name.
6606 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6608 bool DefaultsTest::CompareAndLog(glw::GLfloat value_ref[4], glw::GLfloat value_dst[4], glw::GLenum pname)
6610 if ((de::abs(value_ref[0] - value_dst[0]) > 0.0125 /* Precision */) ||
6611 (de::abs(value_ref[1] - value_dst[1]) > 0.0125 /* Precision */) ||
6612 (de::abs(value_ref[2] - value_dst[2]) > 0.0125 /* Precision */) ||
6613 (de::abs(value_ref[3] - value_dst[3]) > 0.0125 /* Precision */))
6615 m_context.getTestContext().getLog()
6616 << tcu::TestLog::Message << "Queried value of pname " << glu::getTextureParameterStr(pname)
6617 << " is equal to [" << value_dst[0] << ", " << value_dst[1] << ", " << value_dst[2] << ", " << value_dst[3]
6618 << "], however " << value_ref[0] << ", " << value_ref[1] << ", " << value_ref[2] << ", " << value_ref[3]
6619 << "] was expected. Test fails." << tcu::TestLog::EndMessage;
6627 /******************************** Generate Mipmap Test Implementation ********************************/
6629 /** @brief Generate Mipmap Test constructor.
6631 * @param [in] context OpenGL context.
6633 GenerateMipmapTest::GenerateMipmapTest(deqp::Context& context)
6634 : deqp::TestCase(context, "textures_generate_mipmaps", "Textures Generate Mipmap Test")
6636 /* Intentionally left blank. */
6639 /** @brief Generate Mipmap Test cases.
6641 * @return Iteration result.
6643 tcu::TestNode::IterateResult GenerateMipmapTest::iterate()
6645 /* Shortcut for GL functionality. */
6646 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
6648 /* Get context setup. */
6649 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
6650 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
6652 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
6654 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
6659 /* Running tests. */
6661 bool is_error = false;
6663 /* Texture and cpu results storage. */
6664 glw::GLuint texture = 0;
6665 glw::GLubyte* result = DE_NULL;
6669 /* Prepare texture. */
6670 gl.genTextures(1, &texture);
6671 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
6673 gl.bindTexture(GL_TEXTURE_1D, texture);
6674 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
6676 gl.texImage1D(GL_TEXTURE_1D, 0, GL_R8, s_texture_width, 0, GL_RED, GL_UNSIGNED_BYTE, s_texture_data);
6677 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
6679 /* Generate mipmaps with tested function. */
6680 gl.generateTextureMipmap(texture);
6682 glw::GLenum error = GL_NO_ERROR;
6684 if (GL_NO_ERROR != (error = gl.getError()))
6686 m_context.getTestContext().getLog()
6687 << tcu::TestLog::Message << "GenerateTextureMipmap unexpectedly generated error "
6688 << glu::getErrorStr(error) << ". Test fails." << tcu::TestLog::EndMessage;
6693 /* Continue only if mipmaps has been generated. */
6696 result = new glw::GLubyte[s_texture_width];
6698 if (DE_NULL == result)
6703 /* For each mipmap. */
6704 for (glw::GLuint i = 0, j = s_texture_width;
6705 i < s_texture_width_log - 1 /* Do not test single pixel mipmap. */; ++i, j /= 2)
6707 /* Check mipmap size. */
6708 glw::GLint mipmap_size = 0;
6710 gl.getTexLevelParameteriv(GL_TEXTURE_1D, i, GL_TEXTURE_WIDTH, &mipmap_size);
6711 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
6713 if (mipmap_size != (glw::GLint)j)
6715 m_context.getTestContext().getLog()
6716 << tcu::TestLog::Message
6717 << "GenerateTextureMipmap unexpectedly generated mipmap with improper size. Mipmap size is "
6718 << mipmap_size << ", but " << j << " was expected. Test fails." << tcu::TestLog::EndMessage;
6726 gl.getTexImage(GL_TEXTURE_1D, i, GL_RED, GL_UNSIGNED_BYTE, result);
6727 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexImage has failed");
6729 /* Make comparison. */
6730 for (glw::GLuint k = 0; k < j - 1; ++k)
6732 if (((glw::GLint)result[k + 1]) - ((glw::GLint)result[k]) < 0)
6734 m_context.getTestContext().getLog() << tcu::TestLog::Message
6735 << "GenerateTextureMipmap unexpectedly generated improper "
6736 "mipmap (not descending). Test fails."
6737 << tcu::TestLog::EndMessage;
6756 gl.deleteTextures(1, &texture);
6759 if (DE_NULL != result)
6764 while (GL_NO_ERROR != gl.getError())
6767 /* Result's setup. */
6770 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
6776 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
6780 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
6787 /** Reference data. */
6788 const glw::GLubyte GenerateMipmapTest::s_texture_data[] = {
6789 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
6790 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
6791 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
6792 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
6793 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
6794 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131,
6795 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153,
6796 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
6797 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197,
6798 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
6799 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241,
6800 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
6803 /** Reference data parameters. */
6804 const glw::GLuint GenerateMipmapTest::s_texture_width = 256;
6805 const glw::GLuint GenerateMipmapTest::s_texture_width_log = 8;
6807 /******************************** Bind Unit Test Implementation ********************************/
6809 /** @brief Bind Unit Test constructor.
6811 * @param [in] context OpenGL context.
6813 BindUnitTest::BindUnitTest(deqp::Context& context)
6814 : deqp::TestCase(context, "textures_bind_unit", "Textures Bind Unit Test")
6827 /** @brief Bind Unit Test cases.
6829 * @return Iteration result.
6831 tcu::TestNode::IterateResult BindUnitTest::iterate()
6833 /* Get context setup. */
6834 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
6835 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
6837 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
6839 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
6844 /* Running tests. */
6846 bool is_error = false;
6853 CreateVertexArray();
6866 /* Result's setup. */
6869 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
6875 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
6879 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
6886 /** @brief Create test program.
6888 void BindUnitTest::CreateProgram()
6890 /* Shortcut for GL functionality */
6891 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
6895 glw::GLchar const* source;
6896 glw::GLenum const type;
6898 } shader[] = { { s_vertex_shader, GL_VERTEX_SHADER, 0 }, { s_fragment_shader, GL_FRAGMENT_SHADER, 0 } };
6900 glw::GLuint const shader_count = sizeof(shader) / sizeof(shader[0]);
6904 /* Create program. */
6905 m_po = gl.createProgram();
6906 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateProgram call failed.");
6908 /* Shader compilation. */
6910 for (glw::GLuint i = 0; i < shader_count; ++i)
6912 if (DE_NULL != shader[i].source)
6914 shader[i].id = gl.createShader(shader[i].type);
6916 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateShader call failed.");
6918 gl.attachShader(m_po, shader[i].id);
6920 GLU_EXPECT_NO_ERROR(gl.getError(), "glAttachShader call failed.");
6922 gl.shaderSource(shader[i].id, 1, &shader[i].source, NULL);
6924 GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource call failed.");
6926 gl.compileShader(shader[i].id);
6928 GLU_EXPECT_NO_ERROR(gl.getError(), "glCompileShader call failed.");
6930 glw::GLint status = GL_FALSE;
6932 gl.getShaderiv(shader[i].id, GL_COMPILE_STATUS, &status);
6933 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv call failed.");
6935 if (GL_FALSE == status)
6937 glw::GLint log_size = 0;
6938 gl.getShaderiv(shader[i].id, GL_INFO_LOG_LENGTH, &log_size);
6939 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv call failed.");
6941 glw::GLchar* log_text = new glw::GLchar[log_size];
6943 gl.getShaderInfoLog(shader[i].id, log_size, NULL, &log_text[0]);
6945 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Shader compilation has failed.\n"
6946 << "Shader type: " << glu::getShaderTypeStr(shader[i].type)
6948 << "Shader compilation error log:\n"
6950 << "Shader source code:\n"
6951 << shader[i].source << "\n"
6952 << tcu::TestLog::EndMessage;
6956 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderInfoLog call failed.");
6964 gl.linkProgram(m_po);
6966 GLU_EXPECT_NO_ERROR(gl.getError(), "glTransformFeedbackVaryings call failed.");
6968 glw::GLint status = GL_FALSE;
6970 gl.getProgramiv(m_po, GL_LINK_STATUS, &status);
6972 if (GL_TRUE == status)
6974 for (glw::GLuint i = 0; i < shader_count; ++i)
6978 gl.detachShader(m_po, shader[i].id);
6980 GLU_EXPECT_NO_ERROR(gl.getError(), "glDetachShader call failed.");
6986 glw::GLint log_size = 0;
6988 gl.getProgramiv(m_po, GL_INFO_LOG_LENGTH, &log_size);
6990 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramiv call failed.");
6992 glw::GLchar* log_text = new glw::GLchar[log_size];
6994 gl.getProgramInfoLog(m_po, log_size, NULL, &log_text[0]);
6996 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Program linkage has failed due to:\n"
6998 << tcu::TestLog::EndMessage;
7002 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramInfoLog call failed.");
7011 gl.deleteProgram(m_po);
7017 for (glw::GLuint i = 0; i < shader_count; ++i)
7019 if (0 != shader[i].id)
7021 gl.deleteShader(shader[i].id);
7033 /** @brief Create texture.
7035 void BindUnitTest::CreateTextures()
7037 /* Shortcut for GL functionality. */
7038 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7040 /* Prepare texture. */
7041 gl.genTextures(4, m_to);
7042 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
7044 /* Setup pixel sotre modes.*/
7045 gl.pixelStorei(GL_UNPACK_ALIGNMENT, sizeof(glw::GLubyte));
7046 GLU_EXPECT_NO_ERROR(gl.getError(), "glPixelStorei has failed");
7048 gl.pixelStorei(GL_PACK_ALIGNMENT, sizeof(glw::GLubyte));
7049 GLU_EXPECT_NO_ERROR(gl.getError(), "glPixelStorei has failed");
7052 gl.bindTexture(GL_TEXTURE_2D, m_to[0]);
7053 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
7055 gl.texImage2D(GL_TEXTURE_2D, 0, GL_R8, s_texture_width, s_texture_height, 0, GL_RED, GL_UNSIGNED_BYTE,
7057 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
7059 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
7060 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
7061 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri call failed.");
7063 /* Green texture. */
7064 gl.bindTexture(GL_TEXTURE_2D, m_to[1]);
7065 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
7067 gl.texImage2D(GL_TEXTURE_2D, 0, GL_R8, s_texture_width, s_texture_height, 0, GL_RED, GL_UNSIGNED_BYTE,
7069 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
7071 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
7072 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
7073 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri call failed.");
7076 gl.bindTexture(GL_TEXTURE_2D, m_to[2]);
7077 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
7079 gl.texImage2D(GL_TEXTURE_2D, 0, GL_R8, s_texture_width, s_texture_height, 0, GL_RED, GL_UNSIGNED_BYTE,
7081 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
7083 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
7084 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
7085 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri call failed.");
7087 /* Alpha texture. */
7088 gl.bindTexture(GL_TEXTURE_2D, m_to[3]);
7089 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
7091 gl.texImage2D(GL_TEXTURE_2D, 0, GL_R8, s_texture_width, s_texture_height, 0, GL_RED, GL_UNSIGNED_BYTE,
7093 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
7095 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
7096 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
7097 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri call failed.");
7100 /** @brief Create framebuffer.
7102 void BindUnitTest::CreateFrambuffer()
7104 /* Shortcut for GL functionality. */
7105 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7107 /* Prepare framebuffer. */
7108 gl.genFramebuffers(1, &m_fbo);
7109 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
7111 gl.genRenderbuffers(1, &m_rbo);
7112 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
7114 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
7115 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
7117 gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo);
7118 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
7120 gl.renderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, s_texture_width, s_texture_height);
7121 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage call failed.");
7123 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo);
7124 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer call failed.");
7126 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
7131 gl.viewport(0, 0, s_texture_width, s_texture_height);
7132 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
7134 /* Clear framebuffer's content. */
7135 gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
7136 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor call failed.");
7138 gl.clear(GL_COLOR_BUFFER_BIT);
7139 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear call failed.");
7142 /** @brief Create vertex array object.
7144 void BindUnitTest::CreateVertexArray()
7146 /* Shortcut for GL functionality. */
7147 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7149 gl.genVertexArrays(1, &m_vao);
7150 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays call has failed.");
7152 gl.bindVertexArray(m_vao);
7153 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray call has failed.");
7156 bool BindUnitTest::Draw()
7158 /* Shortcut for GL functionality. */
7159 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7161 /* Setup program. */
7162 gl.useProgram(m_po);
7163 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram call has failed.");
7165 /* Bind textures to proper units and setup program's samplers. */
7166 for (glw::GLuint i = 0; i < 4; ++i)
7168 /* Tested binding funcion. */
7169 gl.bindTextureUnit(i, m_to[i]);
7171 /* Check for errors. */
7172 glw::GLenum error = GL_NO_ERROR;
7174 if (GL_NO_ERROR != (error = gl.getError()))
7176 m_context.getTestContext().getLog()
7177 << tcu::TestLog::Message << "BindTextureUnit unexpectedly generated error " << glu::getErrorStr(error)
7178 << " when binding texture " << m_to[i] << " to texture unit " << i << ". Test fails."
7179 << tcu::TestLog::EndMessage;
7184 /* Sampler setup. */
7185 gl.uniform1i(gl.getUniformLocation(m_po, s_fragment_shader_samplers[i]), i);
7186 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation or glUniform1i call has failed.");
7190 gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
7191 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays call has failed.");
7196 /** @brief Compare results with reference.
7198 * @return True if equal, false otherwise.
7200 bool BindUnitTest::Check()
7202 /* Shortcut for GL functionality. */
7203 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7205 /* Setup storage for results. */
7206 m_result = new glw::GLubyte[s_texture_count_rgba];
7208 /* Setup pixel sotre modes.*/
7209 gl.pixelStorei(GL_UNPACK_ALIGNMENT, sizeof(glw::GLubyte));
7210 GLU_EXPECT_NO_ERROR(gl.getError(), "glPixelStorei has failed");
7212 gl.pixelStorei(GL_PACK_ALIGNMENT, sizeof(glw::GLubyte));
7213 GLU_EXPECT_NO_ERROR(gl.getError(), "glPixelStorei has failed");
7215 /* Query framebuffer's image. */
7216 gl.readPixels(0, 0, s_texture_width, s_texture_height, GL_RGBA, GL_UNSIGNED_BYTE, m_result);
7217 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays call has failed.");
7219 /* Compare values with reference. */
7220 for (glw::GLuint i = 0; i < s_texture_count_rgba; ++i)
7222 if (s_texture_data_rgba[i] != m_result[i])
7224 m_context.getTestContext().getLog()
7225 << tcu::TestLog::Message << "Framebuffer data " << DataToString(s_texture_count_rgba, m_result)
7226 << " does not match the reference values " << DataToString(s_texture_count_rgba, s_texture_data_rgba)
7227 << "." << tcu::TestLog::EndMessage;
7236 /** @brief Clean GL objects, test variables and GL errors.
7238 void BindUnitTest::CleanAll()
7240 /* Shortcut for GL functionality. */
7241 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7243 /* Release GL objects. */
7248 gl.deleteProgram(m_po);
7253 if (m_to[0] || m_to[1] || m_to[2] || m_to[3])
7255 gl.deleteTextures(4, m_to);
7265 gl.deleteFramebuffers(1, &m_fbo);
7272 gl.deleteRenderbuffers(1, &m_rbo);
7278 if (DE_NULL != m_result)
7283 /* Erros clean-up. */
7284 while (GL_NO_ERROR != gl.getError())
7288 /** @brief Convert raw data into string for logging purposes.
7290 * @param [in] count Count of the data.
7291 * @param [in] data Raw data.
7293 * @return String representation of data.
7295 std::string BindUnitTest::DataToString(glw::GLuint count, const glw::GLubyte data[])
7297 std::string data_str = "[";
7299 for (glw::GLuint i = 0; i < count; ++i)
7301 std::stringstream int_sstream;
7303 int_sstream << unsigned(data[i]);
7305 data_str.append(int_sstream.str());
7309 data_str.append(", ");
7313 data_str.append("]");
7320 /** Reference data and parameters. */
7321 const glw::GLubyte BindUnitTest::s_texture_data_r[] = { 0, 4, 8, 12, 16, 20 };
7322 const glw::GLubyte BindUnitTest::s_texture_data_g[] = { 1, 5, 9, 13, 17, 21 };
7323 const glw::GLubyte BindUnitTest::s_texture_data_b[] = { 2, 6, 10, 14, 18, 22 };
7324 const glw::GLubyte BindUnitTest::s_texture_data_a[] = { 3, 7, 11, 15, 19, 23 };
7325 const glw::GLubyte BindUnitTest::s_texture_data_rgba[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
7326 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 };
7327 const glw::GLuint BindUnitTest::s_texture_width = 2;
7328 const glw::GLuint BindUnitTest::s_texture_height = 3;
7329 const glw::GLuint BindUnitTest::s_texture_count_rgba = sizeof(s_texture_data_rgba) / sizeof(s_texture_data_rgba[0]);
7331 /* Vertex shader source code. */
7332 const glw::GLchar* BindUnitTest::s_vertex_shader = "#version 450\n"
7336 " switch(gl_VertexID)\n"
7339 " gl_Position = vec4(-1.0, 1.0, 0.0, 1.0);\n"
7342 " gl_Position = vec4( 1.0, 1.0, 0.0, 1.0);\n"
7345 " gl_Position = vec4(-1.0,-1.0, 0.0, 1.0);\n"
7348 " gl_Position = vec4( 1.0,-1.0, 0.0, 1.0);\n"
7353 /* Fragment shader source program. */
7354 const glw::GLchar* BindUnitTest::s_fragment_shader =
7357 "layout(pixel_center_integer) in vec4 gl_FragCoord;\n"
7359 "uniform sampler2D texture_input_r;\n"
7360 "uniform sampler2D texture_input_g;\n"
7361 "uniform sampler2D texture_input_b;\n"
7362 "uniform sampler2D texture_input_a;\n"
7364 "out vec4 color_output;\n"
7368 " color_output = vec4(texelFetch(texture_input_r, ivec2(gl_FragCoord.xy), 0).r,\n"
7369 " texelFetch(texture_input_g, ivec2(gl_FragCoord.xy), 0).r,\n"
7370 " texelFetch(texture_input_b, ivec2(gl_FragCoord.xy), 0).r,\n"
7371 " texelFetch(texture_input_a, ivec2(gl_FragCoord.xy), 0).r);\n"
7374 const glw::GLchar* BindUnitTest::s_fragment_shader_samplers[4] = { "texture_input_r", "texture_input_g",
7375 "texture_input_b", "texture_input_a" };
7377 /******************************** Get Image Test Implementation ********************************/
7379 /** @brief Get Image Test constructor.
7381 * @param [in] context OpenGL context.
7383 GetImageTest::GetImageTest(deqp::Context& context)
7384 : deqp::TestCase(context, "textures_get_image", "Textures Get Image Test")
7386 /* Intentionally left blank */
7389 /** Reference data. */
7390 const glw::GLubyte GetImageTest::s_texture_data[] = { 0x0, 0x0, 0x0, 0xff, 0x7f, 0x7f, 0x7f, 0xff, 0xc3, 0xc3, 0xc3,
7391 0xff, 0xff, 0xff, 0xff, 0xff, 0x88, 0x0, 0x15, 0xff, 0xed, 0x1c,
7392 0x24, 0xff, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x0, 0xff, 0xc8,
7393 0xbf, 0xe7, 0xff, 0x70, 0x92, 0xbe, 0xff, 0x99, 0xd9, 0xea, 0xff,
7394 0xb5, 0xe6, 0x1d, 0xff, 0xa3, 0x49, 0xa4, 0xff, 0x3f, 0x48, 0xcc,
7395 0xff, 0x0, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0xff };
7397 /** Reference data (compressed). */
7398 const glw::GLubyte GetImageTest::s_texture_data_compressed[] = { 0x90, 0x2b, 0x8f, 0x0f, 0xfe, 0x0f, 0x98, 0x99,
7399 0x99, 0x99, 0x59, 0x8f, 0x8c, 0xa6, 0xb7, 0x71 };
7401 /** Reference data parameters. */
7402 const glw::GLuint GetImageTest::s_texture_width = 4;
7403 const glw::GLuint GetImageTest::s_texture_height = 4;
7404 const glw::GLuint GetImageTest::s_texture_size = sizeof(s_texture_data);
7405 const glw::GLuint GetImageTest::s_texture_size_compressed = sizeof(s_texture_data_compressed);
7406 const glw::GLuint GetImageTest::s_texture_count = s_texture_size / sizeof(s_texture_data[0]);
7407 const glw::GLuint GetImageTest::s_texture_count_compressed =
7408 s_texture_size_compressed / sizeof(s_texture_data_compressed[0]);
7410 /** @brief Get Image Test cases.
7412 * @return Iteration result.
7414 tcu::TestNode::IterateResult GetImageTest::iterate()
7416 /* Shortcut for GL functionality. */
7417 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7419 /* Get context setup. */
7420 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
7421 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
7423 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
7425 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
7430 /* Running tests. */
7432 bool is_error = false;
7435 glw::GLuint texture = 0;
7436 glw::GLubyte result[s_texture_count] = {};
7437 glw::GLubyte result_compressed[s_texture_count_compressed] = {};
7441 /* Uncompressed case. */
7443 /* Texture initiation. */
7444 gl.genTextures(1, &texture);
7445 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
7447 gl.bindTexture(GL_TEXTURE_2D, texture);
7448 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
7450 gl.texImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, s_texture_width, s_texture_height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
7452 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
7454 /* Quering image with tested function. */
7455 gl.getTextureImage(texture, 0, GL_RGBA, GL_UNSIGNED_BYTE, sizeof(result), result);
7457 /* Check for errors. */
7458 glw::GLenum error = GL_NO_ERROR;
7460 if (GL_NO_ERROR != (error = gl.getError()))
7462 m_context.getTestContext().getLog()
7463 << tcu::TestLog::Message << "GetTextureImage unexpectedly generated error "
7464 << glu::getErrorStr(error) << ". Test fails." << tcu::TestLog::EndMessage;
7470 /* No error, so compare images. */
7471 for (glw::GLuint i = 0; i < s_texture_count; ++i)
7473 if (s_texture_data[i] != result[i])
7475 m_context.getTestContext().getLog() << tcu::TestLog::Message << "GetTextureImage returned "
7476 << DataToString(s_texture_count, result) << ", but "
7477 << DataToString(s_texture_count, s_texture_data)
7478 << " was expected. Test fails." << tcu::TestLog::EndMessage;
7488 /* Clean up texture .*/
7489 gl.deleteTextures(1, &texture);
7490 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
7494 /* Compressed case. */
7496 /* Texture initiation. */
7497 gl.genTextures(1, &texture);
7498 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
7500 gl.bindTexture(GL_TEXTURE_2D, texture);
7501 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
7503 gl.compressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_BPTC_UNORM, s_texture_width, s_texture_height,
7504 0, s_texture_size_compressed, s_texture_data_compressed);
7505 GLU_EXPECT_NO_ERROR(gl.getError(), "glCompressedTexImage2D has failed");
7507 /* Quering image with tested function. */
7508 gl.getCompressedTextureImage(texture, 0, s_texture_count_compressed * sizeof(result_compressed[0]),
7511 /* Check for errors. */
7512 glw::GLenum error = GL_NO_ERROR;
7514 if (GL_NO_ERROR != (error = gl.getError()))
7516 m_context.getTestContext().getLog()
7517 << tcu::TestLog::Message << "GetCompressedTextureImage unexpectedly generated error "
7518 << glu::getErrorStr(error) << ". Test fails." << tcu::TestLog::EndMessage;
7524 /* No error, so compare images. */
7525 for (glw::GLuint i = 0; i < s_texture_count_compressed; ++i)
7527 if (s_texture_data_compressed[i] != result_compressed[i])
7529 m_context.getTestContext().getLog()
7530 << tcu::TestLog::Message << "GetCompressedTextureImage returned "
7531 << DataToString(s_texture_count_compressed, result_compressed) << ", but "
7532 << DataToString(s_texture_count_compressed, s_texture_data_compressed)
7533 << " was expected. Test fails." << tcu::TestLog::EndMessage;
7552 gl.deleteTextures(1, &texture);
7555 /* Result's setup. */
7558 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
7564 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
7568 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
7575 /** @brief Convert raw data into string for logging purposes.
7577 * @param [in] count Count of the data.
7578 * @param [in] data Raw data.
7580 * @return String representation of data.
7582 std::string GetImageTest::DataToString(glw::GLuint count, const glw::GLubyte data[])
7584 std::string data_str = "[";
7586 for (glw::GLuint i = 0; i < count; ++i)
7588 std::stringstream int_sstream;
7590 int_sstream << unsigned(data[i]);
7592 data_str.append(int_sstream.str());
7596 data_str.append(", ");
7600 data_str.append("]");
7607 /******************************** Get Level Parameter Test Implementation ********************************/
7609 /** @brief Get Level Parameter Test constructor.
7611 * @param [in] context OpenGL context.
7613 GetLevelParameterTest::GetLevelParameterTest(deqp::Context& context)
7614 : deqp::TestCase(context, "textures_get_level_parameter", "Textures Get Level Parameter Test")
7616 /* Intentionally left blank */
7619 /** Reference data. */
7620 const glw::GLubyte GetLevelParameterTest::s_texture_data[] = {
7621 0x0, 0x0, 0x0, 0xff, 0x7f, 0x7f, 0x7f, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff,
7622 0x88, 0x0, 0x15, 0xff, 0xed, 0x1c, 0x24, 0xff, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x0, 0xff,
7623 0xc8, 0xbf, 0xe7, 0xff, 0x70, 0x92, 0xbe, 0xff, 0x99, 0xd9, 0xea, 0xff, 0xb5, 0xe6, 0x1d, 0xff,
7624 0xa3, 0x49, 0xa4, 0xff, 0x3f, 0x48, 0xcc, 0xff, 0x0, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0xff,
7626 0x0, 0x0, 0x0, 0xff, 0x7f, 0x7f, 0x7f, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff,
7627 0x88, 0x0, 0x15, 0xff, 0xed, 0x1c, 0x24, 0xff, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x0, 0xff,
7628 0xc8, 0xbf, 0xe7, 0xff, 0x70, 0x92, 0xbe, 0xff, 0x99, 0xd9, 0xea, 0xff, 0xb5, 0xe6, 0x1d, 0xff,
7629 0xa3, 0x49, 0xa4, 0xff, 0x3f, 0x48, 0xcc, 0xff, 0x0, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0xff,
7631 0x0, 0x0, 0x0, 0xff, 0x7f, 0x7f, 0x7f, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff,
7632 0x88, 0x0, 0x15, 0xff, 0xed, 0x1c, 0x24, 0xff, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x0, 0xff,
7633 0xc8, 0xbf, 0xe7, 0xff, 0x70, 0x92, 0xbe, 0xff, 0x99, 0xd9, 0xea, 0xff, 0xb5, 0xe6, 0x1d, 0xff,
7634 0xa3, 0x49, 0xa4, 0xff, 0x3f, 0x48, 0xcc, 0xff, 0x0, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0xff,
7636 0x0, 0x0, 0x0, 0xff, 0x7f, 0x7f, 0x7f, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff,
7637 0x88, 0x0, 0x15, 0xff, 0xed, 0x1c, 0x24, 0xff, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x0, 0xff,
7638 0xc8, 0xbf, 0xe7, 0xff, 0x70, 0x92, 0xbe, 0xff, 0x99, 0xd9, 0xea, 0xff, 0xb5, 0xe6, 0x1d, 0xff,
7639 0xa3, 0x49, 0xa4, 0xff, 0x3f, 0x48, 0xcc, 0xff, 0x0, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0xff
7642 /** Reference data parameters. */
7643 const glw::GLuint GetLevelParameterTest::s_texture_width = 4;
7644 const glw::GLuint GetLevelParameterTest::s_texture_height = 4;
7645 const glw::GLuint GetLevelParameterTest::s_texture_depth = 4;
7647 /** @brief Get Level Parameter Test cases.
7649 * @return Iteration result.
7651 tcu::TestNode::IterateResult GetLevelParameterTest::iterate()
7653 /* Shortcut for GL functionality. */
7654 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7656 /* Get context setup. */
7657 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
7658 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
7660 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
7662 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
7667 /* Running tests. */
7669 bool is_error = false;
7672 glw::GLuint texture = 0;
7676 /* Texture initiation. */
7677 gl.genTextures(1, &texture);
7678 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
7680 gl.bindTexture(GL_TEXTURE_3D, texture);
7681 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
7683 gl.texImage3D(GL_TEXTURE_3D, 0, GL_RGBA8, s_texture_width, s_texture_height, s_texture_depth, 0, GL_RGBA,
7684 GL_UNSIGNED_BYTE, s_texture_data);
7685 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
7687 gl.texImage3D(GL_TEXTURE_3D, 1, GL_RGBA8, s_texture_width / 2, s_texture_height / 2, s_texture_depth / 2, 0,
7688 GL_RGBA, GL_UNSIGNED_BYTE, s_texture_data);
7689 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
7691 static const glw::GLenum pnames[] = {
7692 GL_TEXTURE_WIDTH, GL_TEXTURE_HEIGHT, GL_TEXTURE_DEPTH, GL_TEXTURE_INTERNAL_FORMAT,
7693 GL_TEXTURE_RED_TYPE, GL_TEXTURE_GREEN_TYPE, GL_TEXTURE_BLUE_TYPE, GL_TEXTURE_ALPHA_TYPE,
7694 GL_TEXTURE_DEPTH_TYPE, GL_TEXTURE_RED_SIZE, GL_TEXTURE_GREEN_SIZE, GL_TEXTURE_BLUE_SIZE,
7695 GL_TEXTURE_ALPHA_SIZE, GL_TEXTURE_DEPTH_SIZE, GL_TEXTURE_COMPRESSED
7697 static const glw::GLuint pnames_count = sizeof(pnames) / sizeof(pnames[0]);
7699 /* Test GetTextureLevelParameteriv. */
7700 for (glw::GLuint i = 0; i < 2 /* levels */; ++i)
7702 for (glw::GLuint j = 0; j < pnames_count; ++j)
7704 glw::GLint result_legacy = 0;
7705 glw::GLint result_dsa = 0;
7707 /* Quering reference value. */
7708 gl.getTexLevelParameteriv(GL_TEXTURE_3D, i, pnames[j], &result_legacy);
7709 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
7711 /* Quering using DSA function. */
7712 gl.getTextureLevelParameteriv(texture, i, pnames[j], &result_dsa);
7714 /* Check for errors. */
7715 glw::GLenum error = GL_NO_ERROR;
7717 if (GL_NO_ERROR != (error = gl.getError()))
7719 m_context.getTestContext().getLog()
7720 << tcu::TestLog::Message << "GetTextureLevelParameteriv unexpectedly generated error "
7721 << glu::getErrorStr(error) << ". Test fails." << tcu::TestLog::EndMessage;
7727 /* Compare values. */
7728 if (result_legacy != result_dsa)
7730 m_context.getTestContext().getLog()
7731 << tcu::TestLog::Message << "For parameter name "
7732 << glu::getTextureLevelParameterStr(pnames[j]) << " GetTextureLevelParameteriv returned "
7733 << result_dsa << ", but reference value (queried using GetTexLevelParameteriv) was "
7734 << result_legacy << ". Test fails." << tcu::TestLog::EndMessage;
7742 /* Test GetTextureLevelParameterfv. */
7743 for (glw::GLuint i = 0; i < 2 /* levels */; ++i)
7745 for (glw::GLuint j = 0; j < pnames_count; ++j)
7747 glw::GLfloat result_legacy = 0.f;
7748 glw::GLfloat result_dsa = 0.f;
7750 /* Quering reference value. */
7751 gl.getTexLevelParameterfv(GL_TEXTURE_3D, i, pnames[j], &result_legacy);
7752 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameterfv has failed");
7754 /* Quering using DSA function. */
7755 gl.getTextureLevelParameterfv(texture, i, pnames[j], &result_dsa);
7757 /* Check for errors. */
7758 glw::GLenum error = GL_NO_ERROR;
7760 if (GL_NO_ERROR != (error = gl.getError()))
7762 m_context.getTestContext().getLog()
7763 << tcu::TestLog::Message << "GetTextureLevelParameterfv unexpectedly generated error "
7764 << glu::getErrorStr(error) << ". Test fails." << tcu::TestLog::EndMessage;
7770 /* Compare values. */
7771 if (de::abs(result_legacy - result_dsa) > 0.125 /* Precision. */)
7773 m_context.getTestContext().getLog()
7774 << tcu::TestLog::Message << "For parameter name "
7775 << glu::getTextureLevelParameterStr(pnames[j]) << " GetTextureLevelParameterfv returned "
7776 << result_dsa << ", but reference value (queried using GetTexLevelParameterfv) was "
7777 << result_legacy << ". Test fails." << tcu::TestLog::EndMessage;
7794 gl.deleteTextures(1, &texture);
7797 while (GL_NO_ERROR != gl.getError())
7800 /* Result's setup. */
7803 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
7809 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
7813 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
7820 /*********************************** Errors Utility Class *****************************************************/
7822 /** @brief Check for errors and log.
7824 * @param [in] context Test's context.
7825 * @param [in] expected_error Expected error value.
7826 * @param [in] function_name Name of the function (to be logged).
7827 * @param [in] log Log message.
7829 * @return True if error is equal to expected, false otherwise.
7831 bool ErrorsUtilities::CheckErrorAndLog(deqp::Context& context, glw::GLuint expected_error,
7832 const glw::GLchar* function_name, const glw::GLchar* log)
7834 /* Shortcut for GL functionality. */
7835 const glw::Functions& gl = context.getRenderContext().getFunctions();
7838 glw::GLenum error = GL_NO_ERROR;
7840 if (expected_error != (error = gl.getError()))
7842 context.getTestContext().getLog() << tcu::TestLog::Message << function_name << " generated error "
7843 << glu::getErrorStr(error) << " but, " << glu::getErrorStr(expected_error)
7844 << " was expected if " << log << tcu::TestLog::EndMessage;
7852 /******************************** Creation Errors Test Implementation ********************************/
7854 /** @brief Creation Errors Test constructor.
7856 * @param [in] context OpenGL context.
7858 CreationErrorsTest::CreationErrorsTest(deqp::Context& context)
7859 : deqp::TestCase(context, "textures_creation_errors", "Texture Objects Creation Errors Test")
7861 /* Intentionally left blank. */
7864 /** @brief Iterate Creation Errors Test cases.
7866 * @return Iteration result.
7868 tcu::TestNode::IterateResult CreationErrorsTest::iterate()
7870 /* Shortcut for GL functionality. */
7871 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7873 /* Get context setup. */
7874 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
7875 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
7877 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
7879 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
7884 /* Running tests. */
7886 bool is_error = false;
7888 /* Textures' objects */
7889 glw::GLuint texture = 0;
7893 /* Not a target test. */
7894 gl.createTextures(NotATarget(), 1, &texture);
7895 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glCreateTextures",
7896 "target is not one of the allowable values.");
7900 gl.deleteTextures(1, &texture);
7905 /* Negative number of textures. */
7906 gl.createTextures(GL_TEXTURE_2D, -1, &texture);
7907 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCreateTextures", "n is negative.");
7918 gl.deleteTextures(1, &texture);
7921 /* Errors clean up. */
7922 while (gl.getError())
7925 /* Result's setup. */
7928 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
7934 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
7938 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
7945 /** @brief Function retruns enum which is not a texture target.
7947 glw::GLenum CreationErrorsTest::NotATarget()
7949 static const glw::GLenum texture_targets[] = { GL_TEXTURE_1D,
7952 GL_TEXTURE_1D_ARRAY,
7953 GL_TEXTURE_2D_ARRAY,
7954 GL_TEXTURE_RECTANGLE,
7955 GL_TEXTURE_CUBE_MAP,
7956 GL_TEXTURE_CUBE_MAP_ARRAY,
7958 GL_TEXTURE_2D_MULTISAMPLE,
7959 GL_TEXTURE_2D_MULTISAMPLE_ARRAY };
7961 glw::GLenum not_a_target = 0;
7962 bool is_target = true;
7970 for (glw::GLuint i = 0; i < sizeof(texture_targets) / sizeof(texture_targets[0]); ++i)
7972 if (texture_targets[i] == not_a_target)
7980 return not_a_target;
7983 /******************************** Texture Buffer Errors Test Implementation ********************************/
7985 /** @brief Texture Buffer Errors Test constructor.
7987 * @param [in] context OpenGL context.
7989 BufferErrorsTest::BufferErrorsTest(deqp::Context& context)
7990 : deqp::TestCase(context, "textures_buffer_errors", "Texture Buffer Errors Test")
7992 /* Intentionally left blank. */
7995 /** @brief Iterate Texture Buffer Errors Test cases.
7997 * @return Iteration result.
7999 tcu::TestNode::IterateResult BufferErrorsTest::iterate()
8001 /* Shortcut for GL functionality. */
8002 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8004 /* Get context setup. */
8005 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
8006 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
8008 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
8010 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
8015 /* Running tests. */
8017 bool is_error = false;
8019 /* Textures' objects */
8020 glw::GLuint texture_buffer = 0;
8021 glw::GLuint texture_1D = 0;
8022 glw::GLuint buffer = 0;
8024 static const glw::GLubyte data[4] = { 1, 2, 3, 4 };
8025 static const glw::GLuint data_size = sizeof(data);
8029 /* Auxiliary objects setup. */
8030 gl.createTextures(GL_TEXTURE_BUFFER, 1, &texture_buffer);
8031 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8033 gl.createTextures(GL_TEXTURE_1D, 1, &texture_1D);
8034 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8036 gl.createBuffers(1, &buffer);
8037 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateBuffers has failed");
8039 gl.namedBufferData(buffer, data_size, data, GL_STATIC_COPY);
8040 GLU_EXPECT_NO_ERROR(gl.getError(), "glNamedBufferData has failed");
8042 /* Check that INVALID_OPERATION is generated by glTextureBuffer if texture
8043 is not the name of an existing texture object. */
8045 glw::GLuint not_a_texture = 0;
8047 while (gl.isTexture(++not_a_texture))
8049 GLU_EXPECT_NO_ERROR(gl.getError(), "glIsTexture has failed");
8051 gl.textureBuffer(not_a_texture, GL_RGBA8, buffer);
8053 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureBuffer",
8054 "texture is not the name of an existing texture object.");
8057 /* Check that INVALID_ENUM is generated by glTextureBuffer if the effective
8058 target of texture is not TEXTURE_BUFFER. */
8060 gl.textureBuffer(texture_1D, GL_RGBA8, buffer);
8062 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureBuffer",
8063 "the effective target of texture is not TEXTURE_BUFFER.");
8066 /* Check that INVALID_ENUM is generated if internalformat is not one of the
8067 sized internal formats described above. */
8069 gl.textureBuffer(texture_buffer, GL_COMPRESSED_SIGNED_RED_RGTC1, buffer);
8071 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureBuffer",
8072 "internalformat is not one of the sized internal formats described above..");
8075 /* Check that INVALID_OPERATION is generated if buffer is not zero and is
8076 not the name of an existing buffer object. */
8078 glw::GLuint not_a_buffer = 0;
8080 while (gl.isBuffer(++not_a_buffer))
8082 GLU_EXPECT_NO_ERROR(gl.getError(), "glIsBuffer has failed");
8084 gl.textureBuffer(texture_buffer, GL_RGBA8, not_a_buffer);
8086 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureBuffer",
8087 "buffer is not zero and is not the name of an existing buffer object.");
8099 gl.deleteTextures(1, &texture_1D);
8104 gl.deleteTextures(1, &texture_buffer);
8109 gl.deleteBuffers(1, &buffer);
8112 /* Errors clean up. */
8113 while (gl.getError())
8116 /* Result's setup. */
8119 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
8125 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
8129 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
8136 /******************************** Texture Buffer Range Errors Test Implementation ********************************/
8138 /** @brief Texture Buffer Range Errors Test constructor.
8140 * @param [in] context OpenGL context.
8142 BufferRangeErrorsTest::BufferRangeErrorsTest(deqp::Context& context)
8143 : deqp::TestCase(context, "textures_buffer_range_errors", "Texture Buffer Range Errors Test")
8145 /* Intentionally left blank. */
8148 /** @brief Iterate Texture Buffer Range Errors Test cases.
8150 * @return Iteration result.
8152 tcu::TestNode::IterateResult BufferRangeErrorsTest::iterate()
8154 /* Shortcut for GL functionality. */
8155 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8157 /* Get context setup. */
8158 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
8159 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
8161 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
8163 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
8168 /* Running tests. */
8170 bool is_error = false;
8172 /* Textures' objects */
8173 glw::GLuint texture_buffer = 0;
8174 glw::GLuint texture_1D = 0;
8175 glw::GLuint buffer = 0;
8177 static const glw::GLubyte data[4] = { 1, 2, 3, 4 };
8178 static const glw::GLuint data_size = sizeof(data);
8182 /* Auxiliary objects setup. */
8183 gl.createTextures(GL_TEXTURE_BUFFER, 1, &texture_buffer);
8184 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8186 gl.createTextures(GL_TEXTURE_1D, 1, &texture_1D);
8187 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8189 gl.createBuffers(1, &buffer);
8190 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateBuffers has failed");
8192 gl.namedBufferData(buffer, data_size, data, GL_STATIC_COPY);
8193 GLU_EXPECT_NO_ERROR(gl.getError(), "glNamedBufferData has failed");
8195 /* Check that INVALID_OPERATION is generated by TextureBufferRange if
8196 texture is not the name of an existing texture object.*/
8198 glw::GLuint not_a_texture = 0;
8200 while (gl.isTexture(++not_a_texture))
8202 GLU_EXPECT_NO_ERROR(gl.getError(), "glIsTexture has failed");
8204 gl.textureBufferRange(not_a_texture, GL_RGBA8, buffer, 0, data_size);
8206 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureBufferRange",
8207 "texture is not the name of an existing texture object.");
8210 /* Check that INVALID_ENUM is generated by TextureBufferRange if the
8211 effective target of texture is not TEXTURE_BUFFER. */
8213 gl.textureBufferRange(texture_1D, GL_RGBA8, buffer, 0, data_size);
8215 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureBufferRange",
8216 "the effective target of texture is not TEXTURE_BUFFER.");
8219 /* Check that INVALID_ENUM is generated by TextureBufferRange if
8220 internalformat is not one of the sized internal formats described above. */
8222 gl.textureBufferRange(texture_buffer, GL_COMPRESSED_SIGNED_RED_RGTC1, buffer, 0, data_size);
8224 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureBufferRange",
8225 "internalformat is not one of the supported sized internal formats.");
8228 /* Check that INVALID_OPERATION is generated by TextureBufferRange if
8229 buffer is not zero and is not the name of an existing buffer object. */
8231 glw::GLuint not_a_buffer = 0;
8233 while (gl.isBuffer(++not_a_buffer))
8235 GLU_EXPECT_NO_ERROR(gl.getError(), "glIsBuffer has failed");
8237 gl.textureBufferRange(texture_buffer, GL_RGBA8, not_a_buffer, 0, data_size);
8239 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureBufferRange",
8240 "buffer is not zero and is not the name of an existing buffer object.");
8243 /* Check that INVALID_VALUE is generated by TextureBufferRange if offset
8244 is negative, if size is less than or equal to zero, or if offset + size
8245 is greater than the value of BUFFER_SIZE for buffer. */
8247 gl.textureBufferRange(texture_buffer, GL_RGBA8, buffer, -1, data_size);
8249 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureBufferRange", "offset is negative.");
8251 gl.textureBufferRange(texture_buffer, GL_RGBA8, buffer, 0, 0);
8253 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureBufferRange", "size is zero.");
8255 gl.textureBufferRange(texture_buffer, GL_RGBA8, buffer, 0, -1);
8257 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureBufferRange", "size is negative.");
8259 gl.textureBufferRange(texture_buffer, GL_RGBA8, buffer, 0, data_size * 16);
8261 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureBufferRange",
8262 "size is greater than the value of BUFFER_SIZE for buffer.");
8265 /* Check that INVALID_VALUE is generated by TextureBufferRange if offset is
8266 not an integer multiple of the value of TEXTURE_BUFFER_OFFSET_ALIGNMENT. */
8268 glw::GLint gl_texture_buffer_offset_alignment = 0;
8270 gl.getIntegerv(GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT, &gl_texture_buffer_offset_alignment);
8272 /* If alignmet is 1 we cannot do anything. Error situtation is impossible then. */
8273 if (gl_texture_buffer_offset_alignment > 1)
8275 gl.textureBufferRange(texture_buffer, GL_RGBA8, buffer, 1, data_size - 1);
8277 is_ok &= CheckErrorAndLog(
8278 m_context, GL_INVALID_VALUE, "glTextureBufferRange",
8279 "offset is not an integer multiple of the value of TEXTURE_BUFFER_OFFSET_ALIGNMENT.");
8292 gl.deleteTextures(1, &texture_1D);
8297 gl.deleteTextures(1, &texture_buffer);
8302 gl.deleteBuffers(1, &buffer);
8305 /* Errors clean up. */
8306 while (gl.getError())
8309 /* Result's setup. */
8312 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
8318 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
8322 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
8329 /******************************** Texture Storage Errors Test Implementation ********************************/
8331 /** @brief Texture Storage Errors Test constructor.
8333 * @param [in] context OpenGL context.
8335 StorageErrorsTest::StorageErrorsTest(deqp::Context& context)
8336 : deqp::TestCase(context, "textures_storage_errors", "Texture Storage Errors Test")
8343 , m_to_2D_ms_immutable(0)
8345 , m_to_3D_ms_immutable(0)
8347 , m_internalformat_invalid(0)
8348 , m_max_texture_size(1)
8350 , m_max_array_texture_layers(1)
8352 /* Intentionally left blank. */
8355 /** @brief Iterate Texture Storage Errors Test cases.
8357 * @return Iteration result.
8359 tcu::TestNode::IterateResult StorageErrorsTest::iterate()
8361 /* Get context setup. */
8362 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
8363 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
8365 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
8367 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
8372 /* Running tests. */
8374 bool is_error = false;
8383 is_ok &= Test2DMultisample();
8384 is_ok &= Test3DMultisample();
8395 /* Result's setup. */
8398 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
8404 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
8408 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
8415 /** @brief Prepare test objects.
8417 void StorageErrorsTest::Prepare()
8419 /* Shortcut for GL functionality. */
8420 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8422 /* Auxiliary objects setup. */
8425 gl.createTextures(GL_TEXTURE_1D, 1, &m_to_1D);
8426 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8429 gl.createTextures(GL_TEXTURE_1D_ARRAY, 1, &m_to_1D_array);
8430 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8433 gl.createTextures(GL_TEXTURE_2D, 1, &m_to_2D);
8434 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8437 gl.createTextures(GL_TEXTURE_2D_ARRAY, 1, &m_to_2D_array);
8438 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8441 gl.createTextures(GL_TEXTURE_3D, 1, &m_to_3D);
8442 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8444 /* 2D Multisample */
8445 gl.createTextures(GL_TEXTURE_2D_MULTISAMPLE, 1, &m_to_2D_ms);
8446 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8448 /* 2D Multisample with storage */
8449 gl.createTextures(GL_TEXTURE_2D_MULTISAMPLE, 1, &m_to_2D_ms_immutable);
8450 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8452 gl.textureStorage2DMultisample(m_to_2D_ms_immutable, 1, GL_R8, 16, 16, false);
8453 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage2DMultisample has failed");
8455 /* 3D Multisample */
8456 gl.createTextures(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, 1, &m_to_3D_ms);
8457 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8459 /* 3D Multisample with storage */
8460 gl.createTextures(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, 1, &m_to_3D_ms_immutable);
8461 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8463 gl.textureStorage3DMultisample(m_to_3D_ms_immutable, 1, GL_R8, 16, 16, 16, false);
8464 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage2DMultisample has failed");
8466 /* Invalid values */
8468 /* invalid texture object */
8469 while (gl.isTexture(++m_to_invalid))
8471 GLU_EXPECT_NO_ERROR(gl.getError(), "glIsTexture has failed");
8473 /* invalid internal format */
8474 static const glw::GLenum all_internal_formats[] = { GL_R8,
8543 GL_COMPRESSED_SRGB_ALPHA,
8544 GL_COMPRESSED_RED_RGTC1,
8545 GL_COMPRESSED_SIGNED_RED_RGTC1,
8546 GL_COMPRESSED_RG_RGTC2,
8547 GL_COMPRESSED_SIGNED_RG_RGTC2,
8548 GL_COMPRESSED_RGBA_BPTC_UNORM,
8549 GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM,
8550 GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT,
8551 GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT,
8552 GL_COMPRESSED_RGB8_ETC2,
8553 GL_COMPRESSED_SRGB8_ETC2,
8554 GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
8555 GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
8556 GL_COMPRESSED_RGBA8_ETC2_EAC,
8557 GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
8558 GL_COMPRESSED_R11_EAC,
8559 GL_COMPRESSED_SIGNED_R11_EAC,
8560 GL_COMPRESSED_RG11_EAC,
8561 GL_COMPRESSED_SIGNED_RG11_EAC,
8562 GL_DEPTH_COMPONENT16,
8563 GL_DEPTH_COMPONENT24,
8564 GL_DEPTH_COMPONENT32,
8565 GL_DEPTH_COMPONENT32F,
8566 GL_DEPTH24_STENCIL8,
8567 GL_DEPTH32F_STENCIL8,
8571 GL_STENCIL_INDEX16 };
8573 static const glw::GLuint all_internal_formats_count =
8574 sizeof(all_internal_formats) / sizeof(all_internal_formats[0]);
8576 bool is_valid = true;
8577 m_internalformat_invalid = 0;
8582 m_internalformat_invalid++;
8583 for (glw::GLuint i = 0; i < all_internal_formats_count; ++i)
8585 if (all_internal_formats[i] == m_internalformat_invalid)
8593 /* Maximum texture size.*/
8594 gl.getIntegerv(GL_MAX_TEXTURE_SIZE, &m_max_texture_size);
8595 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
8597 /* Maximum number of samples. */
8598 gl.getIntegerv(GL_MAX_SAMPLES, &m_max_samples);
8599 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
8601 /* Maximum number of array texture layers. */
8602 gl.getIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &m_max_array_texture_layers);
8603 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
8606 /** @brief Test TextureStorage1D
8608 * @return Test result.
8610 bool StorageErrorsTest::Test1D()
8612 /* Shortcut for GL functionality. */
8613 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8618 /* Check that INVALID_OPERATION is generated by TextureStorage1D if texture
8619 is not the name of an existing texture object. */
8621 gl.textureStorage1D(m_to_invalid, 1, GL_R8, 8);
8622 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage1D",
8623 "texture is not the name of an existing texture object.");
8626 /* Check that INVALID_ENUM is generated by TextureStorage1D if
8627 internalformat is not a valid sized internal format. */
8629 gl.textureStorage1D(m_to_1D, 1, m_internalformat_invalid, 8);
8630 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureStorage1D",
8631 "internalformat is not a valid sized internal format.");
8634 /* Check that INVALID_ENUM is generated by TextureStorage1D if target or
8635 the effective target of texture is not one of the accepted targets
8638 gl.textureStorage1D(m_to_2D, 1, GL_R8, 8);
8639 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage1D",
8640 "the effective target of texture is not one of the accepted targets.");
8643 /* Check that INVALID_VALUE is generated by TextureStorage1D if width or
8644 levels are less than 1. */
8646 gl.textureStorage1D(m_to_1D, 0, GL_R8, 8);
8647 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage1D", "levels is less than 1.");
8649 gl.textureStorage1D(m_to_1D, 1, GL_R8, 0);
8650 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage1D", "width is less than 1.");
8653 /* Check that INVALID_OPERATION is generated by TextureStorage1D if levels
8654 is greater than log2(width)+1. */
8656 gl.textureStorage1D(m_to_1D, 8, GL_R8, 8);
8657 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage1D",
8658 "levels is greater than log2(width)+1.");
8664 /** @brief Test TextureStorage2D
8666 * @return Test result.
8668 bool StorageErrorsTest::Test2D()
8670 /* Shortcut for GL functionality. */
8671 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8676 /* Check that INVALID_OPERATION is generated by TextureStorage2D if
8677 texture is not the name of an existing texture object. */
8679 gl.textureStorage2D(m_to_invalid, 1, GL_R8, 8, 8);
8680 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage2D",
8681 "texture is not the name of an existing texture object.");
8684 /* Check that INVALID_ENUM is generated by TextureStorage2D if
8685 internalformat is not a valid sized internal format. */
8687 gl.textureStorage2D(m_to_2D, 1, m_internalformat_invalid, 8, 8);
8688 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureStorage2D",
8689 "internalformat is not a valid sized internal format.");
8692 /* Check that INVALID_ENUM is generated by TextureStorage2D if target or
8693 the effective target of texture is not one of the accepted targets
8696 gl.textureStorage2D(m_to_1D, 1, GL_R8, 8, 8);
8697 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage2D",
8698 "the effective target of texture is not one of the accepted targets.");
8701 /* Check that INVALID_VALUE is generated by TextureStorage2D if width,
8702 height or levels are less than 1. */
8704 gl.textureStorage2D(m_to_2D, 0, GL_R8, 8, 8);
8705 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage2D", "levels is less than 1.");
8707 gl.textureStorage2D(m_to_2D, 1, GL_R8, 0, 8);
8708 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage2D", "width is less than 1.");
8710 gl.textureStorage2D(m_to_2D, 1, GL_R8, 8, 0);
8711 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage2D", "height is less than 1.");
8714 /* Check that INVALID_OPERATION is generated by TextureStorage2D if target
8715 is TEXTURE_1D_ARRAY or PROXY_TEXTURE_1D_ARRAY and levels is greater than
8718 gl.textureStorage2D(m_to_1D_array, 8, GL_R8, 8, 8);
8719 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage2D",
8720 "target is TEXTURE_1D_ARRAY and levels is greater than log2(width)+1.");
8723 /* Check that INVALID_OPERATION is generated by TextureStorage2D if target
8724 is not TEXTURE_1D_ARRAY or PROXY_TEXTURE_1D_ARRAY and levels is greater
8725 than log2(max(width, height))+1. */
8727 gl.textureStorage2D(m_to_2D, 8, GL_R8, 8, 8);
8728 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage2D",
8729 "target is TEXTURE_2D and levels is greater than log2(max(width, height))+1.");
8735 /** @brief Test TextureStorage3D
8737 * @return Test result.
8739 bool StorageErrorsTest::Test3D()
8741 /* Shortcut for GL functionality. */
8742 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8747 /* Check that INVALID_OPERATION is generated by TextureStorage3D if texture
8748 is not the name of an existing texture object. */
8750 gl.textureStorage3D(m_to_invalid, 1, GL_R8, 8, 8, 8);
8751 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage3D",
8752 "texture is not the name of an existing texture object.");
8755 /* Check that INVALID_ENUM is generated by TextureStorage3D if
8756 internalformat is not a valid sized internal format. */
8758 gl.textureStorage3D(m_to_3D, 1, m_internalformat_invalid, 8, 8, 8);
8759 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureStorage3D",
8760 "internalformat is not a valid sized internal format.");
8763 /* Check that INVALID_ENUM is generated by TextureStorage3D if target or
8764 the effective target of texture is not one of the accepted targets
8767 gl.textureStorage3D(m_to_1D, 1, GL_R8, 8, 8, 8);
8768 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage3D",
8769 "the effective target of texture is not one of the accepted targets.");
8772 /* Check that INVALID_VALUE is generated by TextureStorage3D if width,
8773 height, depth or levels are less than 1. */
8775 gl.textureStorage3D(m_to_3D, 0, GL_R8, 8, 8, 8);
8776 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage3D", "levels is less than 1.");
8778 gl.textureStorage3D(m_to_3D, 1, GL_R8, 0, 8, 8);
8779 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage3D", "width is less than 1.");
8781 gl.textureStorage3D(m_to_3D, 1, GL_R8, 8, 0, 8);
8782 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage3D", "height is less than 1.");
8784 gl.textureStorage3D(m_to_3D, 1, GL_R8, 8, 8, 0);
8785 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage3D", "depth is less than 1.");
8788 /* Check that INVALID_OPERATION is generated by TextureStorage3D if target
8789 is TEXTURE_3D or PROXY_TEXTURE_3D and levels is greater than
8790 log2(max(width, height, depth))+1. */
8792 gl.textureStorage3D(m_to_3D, 8, GL_R8, 8, 8, 8);
8793 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage3D",
8794 "target is TEXTURE_3D and levels is greater than log2(max(width, height, depth))+1.");
8797 /* Check that INVALID_OPERATION is generated by TextureStorage3D if target
8798 is TEXTURE_2D_ARRAY, PROXY_TEXTURE_2D_ARRAY, TEXURE_CUBE_ARRAY,
8799 or PROXY_TEXTURE_CUBE_MAP_ARRAY and levels is greater than
8800 log2(max(width, height))+1. */
8802 gl.textureStorage3D(m_to_2D_array, 6, GL_R8, 8, 8, 256);
8803 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage3D",
8804 "target is TEXTURE_2D_ARRAY and levels is greater than log2(max(width, height))+1.");
8810 /** @brief Test TextureStorage2DMultisample
8812 * @return Test result.
8814 bool StorageErrorsTest::Test2DMultisample()
8816 /* Shortcut for GL functionality. */
8817 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8822 /* Check that INVALID_OPERATION is generated by TextureStorage2DMultisample
8823 if texture is not the name of an existing texture object. */
8825 gl.textureStorage2DMultisample(m_to_invalid, 1, GL_R8, 8, 8, false);
8826 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage2DMultisample",
8827 "texture is not the name of an existing texture object.");
8830 /* Check that INVALID_ENUM is generated by TextureStorage2DMultisample if
8831 internalformat is not a valid color-renderable, depth-renderable or
8832 stencil-renderable format. */
8834 gl.textureStorage2DMultisample(m_to_2D_ms, 1, m_internalformat_invalid, 8, 8, false);
8835 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureStorage2DMultisample",
8836 "internalformat is not a valid sized internal format.");
8839 /* Check that INVALID_OPERATION is generated by TextureStorage2DMultisample if
8840 target or the effective target of texture is not one of the accepted
8841 targets described above. */
8843 gl.textureStorage2DMultisample(m_to_1D, 1, GL_R8, 8, 8, false);
8844 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage2DMultisample",
8845 "the effective target of texture is not one of the accepted targets.");
8848 /* Check that INVALID_VALUE is generated by TextureStorage2DMultisample if
8849 width or height are less than 1 or greater than the value of
8850 MAX_TEXTURE_SIZE. */
8852 gl.textureStorage2DMultisample(m_to_2D_ms, 1, GL_R8, 0, 8, false);
8854 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage2DMultisample", "width is less than 1.");
8856 gl.textureStorage2DMultisample(m_to_2D_ms, 1, GL_R8, 8, 0, false);
8858 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage2DMultisample", "height is less than 1.");
8860 gl.textureStorage2DMultisample(m_to_2D_ms, 1, GL_R8, m_max_texture_size * 2, 8, false);
8861 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage2DMultisample",
8862 "width is greater than the value of MAX_TEXTURE_SIZE.");
8864 gl.textureStorage2DMultisample(m_to_2D_ms, 1, GL_R8, 8, m_max_texture_size * 2, false);
8865 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage2DMultisample",
8866 "height is greater than the value of MAX_TEXTURE_SIZE.");
8869 /* Check that INVALID_OPERATION is generated by TextureStorage2DMultisample if
8870 samples is greater than the value of MAX_SAMPLES. */
8872 gl.textureStorage2DMultisample(m_to_2D_ms, m_max_samples * 2, GL_R8, 8, 8, false);
8873 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage2DMultisample",
8874 "samples is greater than the value of MAX_SAMPLES.");
8877 /* Check that INVALID_OPERATION is generated by TextureStorage2DMultisample
8878 if the value of TEXTURE_IMMUTABLE_FORMAT for the texture bound to target
8881 gl.textureStorage2DMultisample(m_to_2D_ms_immutable, 1, GL_R8, 8, 8, false);
8882 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage2DMultisample",
8883 "samples is greater than the value of MAX_SAMPLES.");
8889 /** @brief Test TextureStorage3DMultisample
8891 * @return Test result.
8893 bool StorageErrorsTest::Test3DMultisample()
8895 /* Shortcut for GL functionality. */
8896 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8901 /* Check that INVALID_OPERATION is generated by TextureStorage3DMultisample
8902 if texture is not the name of an existing texture object. */
8904 gl.textureStorage3DMultisample(m_to_invalid, 1, GL_R8, 8, 8, 8, false);
8905 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage3DMultisample",
8906 "texture is not the name of an existing texture object.");
8909 /* Check that INVALID_ENUM is generated by TextureStorage3DMultisample if
8910 internalformat is not a valid color-renderable, depth-renderable or
8911 stencil-renderable format. */
8913 gl.textureStorage3DMultisample(m_to_3D_ms, 1, m_internalformat_invalid, 8, 8, 8, false);
8914 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureStorage3DMultisample",
8915 "internalformat is not a valid sized internal format.");
8918 /* Check that INVALID_OPERATION is generated by TextureStorage3DMultisample if
8919 target or the effective target of texture is not one of the accepted
8920 targets described above. */
8922 gl.textureStorage3DMultisample(m_to_1D, 1, GL_R8, 8, 8, 8, false);
8923 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage3DMultisample",
8924 "the effective target of texture is not one of the accepted targets.");
8927 /* Check that INVALID_VALUE is generated by TextureStorage3DMultisample if
8928 width or height are less than 1 or greater than the value of
8929 MAX_TEXTURE_SIZE. */
8931 gl.textureStorage3DMultisample(m_to_3D_ms, 1, GL_R8, 0, 8, 8, false);
8933 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage3DMultisample", "width is less than 1.");
8935 gl.textureStorage3DMultisample(m_to_3D_ms, 1, GL_R8, 8, 0, 8, false);
8937 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage3DMultisample", "height is less than 1.");
8939 gl.textureStorage3DMultisample(m_to_3D_ms, 1, GL_R8, m_max_texture_size * 2, 8, 8, false);
8940 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage3DMultisample",
8941 "width is greater than the value of MAX_TEXTURE_SIZE.");
8943 gl.textureStorage3DMultisample(m_to_3D_ms, 1, GL_R8, 8, m_max_texture_size * 2, 8, false);
8944 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage3DMultisample",
8945 "height is greater than the value of MAX_TEXTURE_SIZE.");
8948 /* Check that INVALID_VALUE is generated by TextureStorage3DMultisample if
8949 depth is less than 1 or greater than the value of
8950 MAX_ARRAY_TEXTURE_LAYERS. */
8952 gl.textureStorage3DMultisample(m_to_3D_ms, 1, GL_R8, 8, 8, 0, false);
8954 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage3DMultisample", "depth is less than 1.");
8956 gl.textureStorage3DMultisample(m_to_3D_ms, 1, GL_R8, 8, 8, m_max_array_texture_layers * 2, false);
8957 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage3DMultisample",
8958 "depth is greater than the value of MAX_ARRAY_TEXTURE_LAYERS.");
8961 /* Check that INVALID_VALUE is generated by TextureStorage3DMultisample if
8962 samples is greater than the value of MAX_SAMPLES. */
8964 gl.textureStorage3DMultisample(m_to_3D_ms, m_max_samples * 2, GL_R8, 8, 8, 8, false);
8965 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage3DMultisample",
8966 "samples is greater than the value of MAX_SAMPLES.");
8969 /* Check that INVALID_OPERATION is generated by TextureStorage3DMultisample
8970 if the value of TEXTURE_IMMUTABLE_FORMAT for the texture bound to target
8973 gl.textureStorage3DMultisample(m_to_3D_ms_immutable, 1, GL_R8, 8, 8, 8, false);
8974 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage3DMultisample",
8975 "samples is greater than the value of MAX_SAMPLES.");
8981 /** @brief Clean GL objects, test variables and GL errors.
8983 void StorageErrorsTest::Clean()
8985 /* Shortcut for GL functionality. */
8986 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8991 gl.deleteTextures(1, &m_to_1D);
8998 gl.deleteTextures(1, &m_to_1D_array);
9005 gl.deleteTextures(1, &m_to_2D);
9012 gl.deleteTextures(1, &m_to_2D_array);
9019 gl.deleteTextures(1, &m_to_3D);
9026 gl.deleteTextures(1, &m_to_2D_ms);
9031 if (m_to_2D_ms_immutable)
9033 gl.deleteTextures(1, &m_to_2D_ms_immutable);
9035 m_to_2D_ms_immutable = 0;
9040 gl.deleteTextures(1, &m_to_3D_ms);
9045 if (m_to_3D_ms_immutable)
9047 gl.deleteTextures(1, &m_to_3D_ms_immutable);
9049 m_to_3D_ms_immutable = 0;
9053 m_internalformat_invalid = 0;
9054 m_max_texture_size = 1;
9056 m_max_array_texture_layers = 1;
9058 while (GL_NO_ERROR != gl.getError())
9062 /******************************** Texture SubImage Errors Test Implementation ********************************/
9064 /** @brief Texture SubImage Errors Test constructor.
9066 * @param [in] context OpenGL context.
9068 SubImageErrorsTest::SubImageErrorsTest(deqp::Context& context)
9069 : deqp::TestCase(context, "textures_subimage_errors", "Texture SubImage Errors Test")
9076 , m_to_1D_compressed(0)
9077 , m_to_2D_compressed(0)
9078 , m_to_3D_compressed(0)
9079 , m_to_rectangle_compressed(0)
9082 , m_format_invalid(0)
9084 , m_max_texture_size(1)
9085 , m_reference_compressed_1D(DE_NULL)
9086 , m_reference_compressed_2D(DE_NULL)
9087 , m_reference_compressed_3D(DE_NULL)
9088 , m_reference_compressed_rectangle(DE_NULL)
9089 , m_reference_compressed_1D_size(0)
9090 , m_reference_compressed_2D_size(0)
9091 , m_reference_compressed_3D_size(0)
9092 , m_reference_compressed_rectangle_size(0)
9093 , m_reference_compressed_1D_format(0)
9094 , m_reference_compressed_2D_format(0)
9095 , m_reference_compressed_3D_format(0)
9096 , m_reference_compressed_rectangle_format(0)
9097 , m_not_matching_compressed_1D_format(0)
9098 , m_not_matching_compressed_1D_size(0)
9099 , m_not_matching_compressed_2D_format(0)
9100 , m_not_matching_compressed_2D_size(0)
9101 , m_not_matching_compressed_3D_format(0)
9102 , m_not_matching_compressed_3D_size(0)
9104 /* Intentionally left blank. */
9107 /** @brief Iterate Texture SubImage Errors Test cases.
9109 * @return Iteration result.
9111 tcu::TestNode::IterateResult SubImageErrorsTest::iterate()
9113 /* Get context setup. */
9114 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
9115 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
9117 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
9119 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
9124 /* Running tests. */
9126 bool is_error = false;
9135 is_ok &= Test1DCompressed();
9136 is_ok &= Test2DCompressed();
9137 is_ok &= Test3DCompressed();
9148 /* Result's setup. */
9151 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
9157 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
9161 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
9168 /** @brief Prepare test's objects.
9170 void SubImageErrorsTest::Prepare()
9172 /* Shortcut for GL functionality. */
9173 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
9175 /* Auxiliary objects setup. */
9178 gl.createTextures(GL_TEXTURE_1D, 1, &m_to_1D_empty);
9179 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9182 gl.createTextures(GL_TEXTURE_2D, 1, &m_to_2D_empty);
9183 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9186 gl.createTextures(GL_TEXTURE_3D, 1, &m_to_3D_empty);
9187 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9190 gl.createTextures(GL_TEXTURE_1D, 1, &m_to_1D);
9191 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9193 gl.bindTexture(GL_TEXTURE_1D, m_to_1D);
9194 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
9196 gl.texImage1D(GL_TEXTURE_1D, 0, s_reference_internalformat, s_reference_width, 0, s_reference_format,
9197 GL_UNSIGNED_BYTE, s_reference);
9198 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
9201 gl.createTextures(GL_TEXTURE_2D, 1, &m_to_2D);
9202 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9204 gl.bindTexture(GL_TEXTURE_2D, m_to_2D);
9205 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
9207 gl.texImage2D(GL_TEXTURE_2D, 0, s_reference_internalformat, s_reference_width, s_reference_height, 0,
9208 s_reference_format, GL_UNSIGNED_BYTE, s_reference);
9209 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
9212 gl.createTextures(GL_TEXTURE_3D, 1, &m_to_3D);
9213 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9215 gl.bindTexture(GL_TEXTURE_3D, m_to_3D);
9216 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
9218 gl.texImage3D(GL_TEXTURE_3D, 0, s_reference_internalformat, s_reference_width, s_reference_height,
9219 s_reference_depth, 0, s_reference_format, GL_UNSIGNED_BYTE, s_reference);
9220 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
9223 gl.createTextures(GL_TEXTURE_1D, 1, &m_to_1D_compressed);
9224 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9226 gl.bindTexture(GL_TEXTURE_1D, m_to_1D_compressed);
9227 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
9229 gl.texImage1D(GL_TEXTURE_1D, 0, s_reference_internalformat_compressed, s_reference_width, 0, s_reference_format,
9230 GL_UNSIGNED_BYTE, s_reference);
9231 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
9233 glw::GLint is_compressed = 0;
9235 gl.getTexLevelParameteriv(GL_TEXTURE_1D, 0, GL_TEXTURE_COMPRESSED, &is_compressed);
9236 GLU_EXPECT_NO_ERROR(gl.getError(), "glTetTexLevelParameteriv has failed");
9240 gl.getTexLevelParameteriv(GL_TEXTURE_1D, 0, GL_TEXTURE_INTERNAL_FORMAT, &m_reference_compressed_1D_format);
9241 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9243 m_reference_compressed_1D_size = 0;
9245 gl.getTexLevelParameteriv(GL_TEXTURE_1D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &m_reference_compressed_1D_size);
9246 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9248 if (m_reference_compressed_1D_size)
9250 m_reference_compressed_1D = new glw::GLubyte[m_reference_compressed_1D_size];
9252 gl.getCompressedTexImage(GL_TEXTURE_1D, 0, m_reference_compressed_1D);
9253 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
9258 gl.createTextures(GL_TEXTURE_2D, 1, &m_to_2D_compressed);
9259 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9261 gl.bindTexture(GL_TEXTURE_2D, m_to_2D_compressed);
9262 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
9264 gl.texImage2D(GL_TEXTURE_2D, 0, s_reference_internalformat_compressed, s_reference_width, s_reference_height, 0,
9265 s_reference_format, GL_UNSIGNED_BYTE, s_reference);
9266 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
9270 gl.getTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED, &is_compressed);
9271 GLU_EXPECT_NO_ERROR(gl.getError(), "glTetTexLevelParameteriv has failed");
9275 gl.getTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &m_reference_compressed_2D_format);
9276 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9278 m_reference_compressed_2D_size = 0;
9280 gl.getTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &m_reference_compressed_2D_size);
9281 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9283 if (m_reference_compressed_2D_size)
9285 m_reference_compressed_2D = new glw::GLubyte[m_reference_compressed_2D_size];
9287 gl.getCompressedTexImage(GL_TEXTURE_2D, 0, m_reference_compressed_2D);
9288 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
9293 gl.createTextures(GL_TEXTURE_2D_ARRAY, 1, &m_to_3D_compressed);
9294 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9296 gl.bindTexture(GL_TEXTURE_2D_ARRAY, m_to_3D_compressed);
9297 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
9299 gl.texImage3D(GL_TEXTURE_2D_ARRAY, 0, s_reference_internalformat_compressed, s_reference_width, s_reference_height,
9300 s_reference_depth, 0, s_reference_format, GL_UNSIGNED_BYTE, s_reference);
9301 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage3D has failed");
9305 gl.getTexLevelParameteriv(GL_TEXTURE_2D_ARRAY, 0, GL_TEXTURE_COMPRESSED, &is_compressed);
9306 GLU_EXPECT_NO_ERROR(gl.getError(), "glTetTexLevelParameteriv has failed");
9310 gl.getTexLevelParameteriv(GL_TEXTURE_2D_ARRAY, 0, GL_TEXTURE_INTERNAL_FORMAT,
9311 &m_reference_compressed_3D_format);
9312 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9314 m_reference_compressed_3D_size = 0;
9316 gl.getTexLevelParameteriv(GL_TEXTURE_2D_ARRAY, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE,
9317 &m_reference_compressed_3D_size);
9318 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9320 if (m_reference_compressed_3D_size)
9322 m_reference_compressed_3D = new glw::GLubyte[m_reference_compressed_3D_size];
9324 gl.getCompressedTexImage(GL_TEXTURE_2D_ARRAY, 0, m_reference_compressed_3D);
9325 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
9329 /* RECTANGLE Compressed */
9330 gl.createTextures(GL_TEXTURE_RECTANGLE, 1, &m_to_rectangle_compressed);
9331 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9333 gl.bindTexture(GL_TEXTURE_RECTANGLE, m_to_rectangle_compressed);
9334 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
9336 gl.texImage2D(GL_TEXTURE_RECTANGLE, 0, s_reference_internalformat_compressed, s_reference_width, s_reference_height,
9337 0, s_reference_format, GL_UNSIGNED_BYTE, s_reference);
9338 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
9342 gl.getTexLevelParameteriv(GL_TEXTURE_RECTANGLE, 0, GL_TEXTURE_COMPRESSED, &is_compressed);
9343 GLU_EXPECT_NO_ERROR(gl.getError(), "glTetTexLevelParameteriv has failed");
9347 gl.getTexLevelParameteriv(GL_TEXTURE_RECTANGLE, 0, GL_TEXTURE_INTERNAL_FORMAT,
9348 &m_reference_compressed_rectangle_format);
9349 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9351 m_reference_compressed_rectangle_size = 0;
9353 gl.getTexLevelParameteriv(GL_TEXTURE_RECTANGLE, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE,
9354 &m_reference_compressed_rectangle_size);
9355 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9357 if (m_reference_compressed_rectangle_size)
9359 m_reference_compressed_rectangle = new glw::GLubyte[m_reference_compressed_rectangle_size];
9361 gl.getCompressedTexImage(GL_TEXTURE_RECTANGLE, 0, m_reference_compressed_rectangle);
9362 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
9367 gl.createBuffers(1, &m_bo);
9368 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateBuffers has failed");
9370 gl.namedBufferData(m_bo, s_reference_size, s_reference, GL_STATIC_COPY);
9371 GLU_EXPECT_NO_ERROR(gl.getError(), "glNamedBufferData has failed");
9373 /* Invalid values */
9375 /* invalid texture object */
9376 while (gl.isTexture(++m_to_invalid))
9378 GLU_EXPECT_NO_ERROR(gl.getError(), "glIsTexture has failed");
9380 /* invalid internal format */
9381 static const glw::GLenum all_formats[] = { GL_STENCIL_INDEX,
9401 static const glw::GLuint all_internal_formats_count = sizeof(all_formats) / sizeof(all_formats[0]);
9403 bool is_valid = true;
9404 m_format_invalid = 0;
9410 for (glw::GLuint i = 0; i < all_internal_formats_count; ++i)
9412 if (all_formats[i] == m_format_invalid)
9421 static const glw::GLenum all_types[] = { GL_UNSIGNED_BYTE,
9429 GL_UNSIGNED_BYTE_3_3_2,
9430 GL_UNSIGNED_BYTE_2_3_3_REV,
9431 GL_UNSIGNED_SHORT_5_6_5,
9432 GL_UNSIGNED_SHORT_5_6_5_REV,
9433 GL_UNSIGNED_SHORT_4_4_4_4,
9434 GL_UNSIGNED_SHORT_4_4_4_4_REV,
9435 GL_UNSIGNED_SHORT_5_5_5_1,
9436 GL_UNSIGNED_SHORT_1_5_5_5_REV,
9437 GL_UNSIGNED_INT_8_8_8_8,
9438 GL_UNSIGNED_INT_8_8_8_8_REV,
9439 GL_UNSIGNED_INT_10_10_10_2,
9440 GL_UNSIGNED_INT_2_10_10_10_REV,
9441 GL_UNSIGNED_INT_24_8,
9442 GL_UNSIGNED_INT_10F_11F_11F_REV,
9443 GL_UNSIGNED_INT_5_9_9_9_REV,
9444 GL_FLOAT_32_UNSIGNED_INT_24_8_REV };
9446 static const glw::GLuint all_types_count = sizeof(all_types) / sizeof(all_types[0]);
9455 for (glw::GLuint i = 0; i < all_types_count; ++i)
9457 if (all_types[i] == m_type_invalid)
9465 /* Maximum texture size.*/
9466 gl.getIntegerv(GL_MAX_TEXTURE_SIZE, &m_max_texture_size);
9467 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
9469 glw::GLenum not_matching_format = GL_RED;
9470 glw::GLenum not_matching_internalformat_compressed = GL_COMPRESSED_RED;
9472 /* 1D Compressed with a non matching format. We need to do all the allocation to get the correct image size */
9473 glw::GLuint to_1D_compressed_not_matching;
9475 gl.createTextures(GL_TEXTURE_1D, 1, &to_1D_compressed_not_matching);
9476 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9478 gl.bindTexture(GL_TEXTURE_1D, to_1D_compressed_not_matching);
9479 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
9481 gl.texImage1D(GL_TEXTURE_1D, 0, not_matching_internalformat_compressed, s_reference_width, 0, s_reference_format,
9482 GL_UNSIGNED_BYTE, s_reference);
9483 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
9487 gl.getTexLevelParameteriv(GL_TEXTURE_1D, 0, GL_TEXTURE_COMPRESSED, &is_compressed);
9488 GLU_EXPECT_NO_ERROR(gl.getError(), "glTetTexLevelParameteriv has failed");
9492 gl.getTexLevelParameteriv(GL_TEXTURE_1D, 0, GL_TEXTURE_INTERNAL_FORMAT, &m_not_matching_compressed_1D_format);
9493 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9495 m_not_matching_compressed_1D_size = 0;
9497 gl.getTexLevelParameteriv(GL_TEXTURE_1D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE,
9498 &m_not_matching_compressed_1D_size);
9499 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9502 gl.deleteTextures(1, &to_1D_compressed_not_matching);
9503 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9505 /* 2D Compressed with a non matching format. We need to do all the allocation to get the correct image size */
9506 glw::GLuint to_2D_compressed_not_matching;
9508 gl.createTextures(GL_TEXTURE_2D, 1, &to_2D_compressed_not_matching);
9509 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9511 gl.bindTexture(GL_TEXTURE_2D, to_2D_compressed_not_matching);
9512 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
9514 gl.texImage2D(GL_TEXTURE_2D, 0, not_matching_internalformat_compressed, s_reference_width, s_reference_height, 0,
9515 not_matching_format, GL_UNSIGNED_BYTE, s_reference);
9516 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
9520 gl.getTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED, &is_compressed);
9521 GLU_EXPECT_NO_ERROR(gl.getError(), "glTetTexLevelParameteriv has failed");
9525 gl.getTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &m_not_matching_compressed_2D_format);
9526 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9528 m_not_matching_compressed_2D_size = 0;
9530 gl.getTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE,
9531 &m_not_matching_compressed_2D_size);
9532 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9535 gl.deleteTextures(1, &to_2D_compressed_not_matching);
9536 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9538 /* 3D Compressed with a non matching format. We need to do all the allocation to get the correct image size */
9539 glw::GLuint to_3D_compressed_not_matching;
9541 gl.createTextures(GL_TEXTURE_3D, 1, &to_3D_compressed_not_matching);
9542 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9544 gl.bindTexture(GL_TEXTURE_3D, to_3D_compressed_not_matching);
9545 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
9547 gl.texImage3D(GL_TEXTURE_3D, 0, not_matching_internalformat_compressed, s_reference_width, s_reference_height,
9548 s_reference_depth, 0, not_matching_format, GL_UNSIGNED_BYTE, s_reference);
9549 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage3D has failed");
9553 gl.getTexLevelParameteriv(GL_TEXTURE_3D, 0, GL_TEXTURE_COMPRESSED, &is_compressed);
9554 GLU_EXPECT_NO_ERROR(gl.getError(), "glTetTexLevelParameteriv has failed");
9558 gl.getTexLevelParameteriv(GL_TEXTURE_3D, 0, GL_TEXTURE_INTERNAL_FORMAT, &m_not_matching_compressed_3D_format);
9559 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9561 m_not_matching_compressed_3D_size = 0;
9563 gl.getTexLevelParameteriv(GL_TEXTURE_3D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE,
9564 &m_not_matching_compressed_3D_size);
9565 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9568 gl.deleteTextures(1, &to_3D_compressed_not_matching);
9569 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9572 /** @brief Test (negative) of TextureSubImage1D
9574 * @return Test result.
9576 bool SubImageErrorsTest::Test1D()
9578 /* Shortcut for GL functionality. */
9579 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
9584 /* Check that INVALID_OPERATION is generated by TextureSubImage1D if
9585 texture is not the name of an existing texture object. */
9587 gl.textureSubImage1D(m_to_invalid, 0, 0, s_reference_width, s_reference_format, s_reference_type, s_reference);
9588 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9589 "texture is not the name of an existing texture object.");
9592 /* Check that INVALID_ENUM is generated by TextureSubImage1D if format is
9593 not an accepted format constant. */
9595 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, m_format_invalid, s_reference_type, s_reference);
9596 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureSubImage1D",
9597 "format is not an accepted format constant.");
9600 /* Check that INVALID_ENUM is generated by TextureSubImage1D if type is not
9601 an accepted type constant. */
9603 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, m_type_invalid, s_reference);
9604 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureSubImage1D",
9605 "type is not an accepted type constant.");
9608 /* Check that INVALID_VALUE is generated by TextureSubImage1D if level is
9611 gl.textureSubImage1D(m_to_1D, -1, 0, s_reference_width, s_reference_format, s_reference_type, s_reference);
9612 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage1D", "level is less than 0.");
9615 /* Check that INVALID_VALUE may be generated by TextureSubImage1D if level
9616 is greater than log2 max, where max is the returned value of
9617 MAX_TEXTURE_SIZE. */
9619 gl.textureSubImage1D(m_to_1D, m_max_texture_size, 0, s_reference_width, s_reference_format, s_reference_type,
9622 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage1D",
9623 "level is greater than log2 max, where max is the returned value of MAX_TEXTURE_SIZE.");
9626 /* Check that INVALID_VALUE is generated by TextureSubImage1D if
9627 xoffset<-b, or if (xoffset+width)>(w-b), where w is the TEXTURE_WIDTH,
9628 and b is the width of the TEXTURE_BORDER of the texture image being
9629 modified. Note that w includes twice the border width. */
9631 gl.textureSubImage1D(m_to_1D, 0, -1, s_reference_width, s_reference_format, s_reference_type, s_reference);
9632 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage1D",
9633 "xoffset<-b, where b is the width of the TEXTURE_BORDER.");
9635 gl.textureSubImage1D(m_to_1D, 0, 1, s_reference_width + 1, s_reference_format, s_reference_type, s_reference);
9636 is_ok &= CheckErrorAndLog(
9637 m_context, GL_INVALID_VALUE, "glTextureSubImage1D",
9638 "(xoffset+width)>(w-b), where w is the TEXTURE_WIDTH, b is the width of the TEXTURE_BORDER.");
9641 /*Check that INVALID_VALUE is generated by TextureSubImage1D if width is less than 0. */
9643 #ifndef TURN_OFF_SUB_IMAGE_ERRORS_TEST_OF_NEGATIVE_WIDTH_HEIGHT_OR_DEPTH
9644 gl.textureSubImage1D(m_to_1D, 0, 0, -1, s_reference_format, s_reference_type, s_reference);
9645 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage1D", "width is less than 0.");
9649 /* Check that INVALID_OPERATION is generated by TextureSubImage1D if type
9650 is one of UNSIGNED_BYTE_3_3_2, UNSIGNED_BYTE_2_3_3_REV,
9651 UNSIGNED_SHORT_5_6_5, or UNSIGNED_SHORT_5_6_5_REV and format is not RGB. */
9653 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_BYTE_3_3_2, s_reference);
9654 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9655 "type is UNSIGNED_BYTE_3_3_2 and format is not RGB.");
9657 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_BYTE_2_3_3_REV,
9659 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9660 "type is UNSIGNED_BYTE_2_3_3_REV and format is not RGB.");
9662 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_SHORT_5_6_5,
9664 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9665 "type is UNSIGNED_SHORT_5_6_5 and format is not RGB.");
9667 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_SHORT_5_6_5_REV,
9669 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9670 "type is UNSIGNED_SHORT_5_6_5_REV and format is not RGB.");
9673 /* Check that INVALID_OPERATION is generated by TextureSubImage1D if type
9674 is one of UNSIGNED_SHORT_4_4_4_4, UNSIGNED_SHORT_4_4_4_4_REV,
9675 UNSIGNED_SHORT_5_5_5_1, UNSIGNED_SHORT_1_5_5_5_REV,
9676 UNSIGNED_INT_8_8_8_8, UNSIGNED_INT_8_8_8_8_REV, UNSIGNED_INT_10_10_10_2,
9677 or UNSIGNED_INT_2_10_10_10_REV and format is neither RGBA nor BGRA. */
9679 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_SHORT_4_4_4_4,
9681 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9682 "type is UNSIGNED_SHORT_4_4_4_4 and format is neither RGBA nor BGRA.");
9684 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_SHORT_4_4_4_4_REV,
9686 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9687 "type is UNSIGNED_SHORT_4_4_4_4_REV and format is neither RGBA nor BGRA.");
9689 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_SHORT_5_5_5_1,
9691 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9692 "type is UNSIGNED_SHORT_5_5_5_1 and format is neither RGBA nor BGRA.");
9694 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_SHORT_1_5_5_5_REV,
9696 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9697 "type is UNSIGNED_SHORT_1_5_5_5_REV and format is neither RGBA nor BGRA.");
9699 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_INT_8_8_8_8,
9701 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9702 "type is UNSIGNED_INT_8_8_8_8 and format is neither RGBA nor BGRA.");
9704 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_INT_8_8_8_8_REV,
9706 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9707 "type is UNSIGNED_INT_8_8_8_8_REV and format is neither RGBA nor BGRA.");
9709 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_INT_10_10_10_2,
9711 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9712 "type is UNSIGNED_INT_10_10_10_2 and format is neither RGBA nor BGRA.");
9714 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_INT_2_10_10_10_REV,
9716 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9717 "type is UNSIGNED_INT_2_10_10_10_REV and format is neither RGBA nor BGRA.");
9720 /* Check that INVALID_OPERATION is generated by TextureSubImage1D if a
9721 non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
9722 and the buffer object's data store is currently mapped. */
9724 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
9725 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9727 gl.mapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_READ_WRITE);
9729 if (GL_NO_ERROR == gl.getError())
9731 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, s_reference_type, NULL);
9732 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9733 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and "
9734 "the buffer object's data store is currently mapped.");
9736 gl.unmapBuffer(GL_PIXEL_UNPACK_BUFFER);
9737 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9739 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
9740 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9744 /* Check that INVALID_OPERATION is generated by TextureSubImage1D if a
9745 non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
9746 and the data would be unpacked from the buffer object such that the
9747 memory reads required would exceed the data store size. */
9749 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
9750 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9752 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, s_reference_type,
9753 (glw::GLubyte*)NULL + s_reference_size * 2);
9754 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9755 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and the "
9756 "data would be unpacked from the buffer object such that the memory reads required "
9757 "would exceed the data store size.");
9759 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
9760 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9763 /* Check that INVALID_OPERATION is generated by TextureSubImage1D if a
9764 non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
9765 and pixels is not evenly divisible into the number of bytes needed to
9766 store in memory a datum indicated by type. */
9768 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
9769 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9771 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, s_reference_type,
9772 (glw::GLubyte*)NULL + 1);
9773 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9774 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and pixels "
9775 "is not evenly divisible into the number of bytes needed to store in memory a datum "
9776 "indicated by type.");
9778 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
9779 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9785 /** @brief Test (negative) of TextureSubImage2D
9787 * @return Test result.
9789 bool SubImageErrorsTest::Test2D()
9791 /* Shortcut for GL functionality. */
9792 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
9797 /* Check that INVALID_OPERATION is generated by TextureSubImage2D if
9798 texture is not the name of an existing texture object. */
9800 gl.textureSubImage2D(m_to_invalid, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9801 s_reference_type, s_reference);
9802 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9803 "texture is not the name of an existing texture object.");
9806 /* Check that INVALID_ENUM is generated by TextureSubImage2D if format is
9807 not an accepted format constant. */
9809 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, m_format_invalid,
9810 s_reference_type, s_reference);
9811 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureSubImage2D",
9812 "format is not an accepted format constant.");
9815 /* Check that INVALID_ENUM is generated by TextureSubImage2D if type is not
9816 an accepted type constant. */
9818 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9819 m_type_invalid, s_reference);
9820 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureSubImage2D",
9821 "type is not an accepted type constant.");
9824 /* Check that INVALID_VALUE is generated by TextureSubImage2D if level is
9827 gl.textureSubImage2D(m_to_2D, -1, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9828 s_reference_type, s_reference);
9829 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage2D", "level is less than 0.");
9832 /* Check that INVALID_VALUE may be generated by TextureSubImage2D if level
9833 is greater than log2 max, where max is the returned value of
9834 MAX_TEXTURE_SIZE. */
9836 gl.textureSubImage2D(m_to_2D, m_max_texture_size, 0, 0, s_reference_width, s_reference_height,
9837 s_reference_format, s_reference_type, s_reference);
9839 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage2D",
9840 "level is greater than log2 max, where max is the returned value of MAX_TEXTURE_SIZE.");
9843 /* Check that INVALID_VALUE may be generated by TextureSubImage2D if level
9844 is greater than log2 max, where max is the returned value of
9846 Check that INVALID_VALUE is generated by TextureSubImage2D if
9847 xoffset<-b, (xoffset+width)>(w-b), yoffset<-b, or
9848 (yoffset+height)>(h-b), where w is the TEXTURE_WIDTH, h is the
9849 TEXTURE_HEIGHT, and b is the border width of the texture image being
9850 modified. Note that w and h include twice the border width. */
9852 gl.textureSubImage2D(m_to_2D, 0, -1, 0, s_reference_width, s_reference_height, s_reference_format,
9853 s_reference_type, s_reference);
9854 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage2D",
9855 "xoffset<-b, where b is the width of the TEXTURE_BORDER.");
9857 gl.textureSubImage2D(m_to_2D, 0, 1, 0, s_reference_width + 1, s_reference_height, s_reference_format,
9858 s_reference_type, s_reference);
9859 is_ok &= CheckErrorAndLog(
9860 m_context, GL_INVALID_VALUE, "glTextureSubImage2D",
9861 "(xoffset+width)>(w-b), where w is the TEXTURE_WIDTH, b is the width of the TEXTURE_BORDER.");
9863 gl.textureSubImage2D(m_to_2D, 0, 0, -1, s_reference_width, s_reference_height, s_reference_format,
9864 s_reference_type, s_reference);
9865 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage2D",
9866 "yoffset<-b, where b is the height of the TEXTURE_BORDER.");
9868 gl.textureSubImage2D(m_to_2D, 0, 0, 1, s_reference_width + 1, s_reference_height, s_reference_format,
9869 s_reference_type, s_reference);
9870 is_ok &= CheckErrorAndLog(
9871 m_context, GL_INVALID_VALUE, "glTextureSubImage2D",
9872 "(yoffset+height)>(h-b), where h is the TEXTURE_HEIGHT, b is the width of the TEXTURE_BORDER.");
9875 /*Check that INVALID_VALUE is generated by TextureSubImage2D if width or height is less than 0. */
9877 #ifndef TURN_OFF_SUB_IMAGE_ERRORS_TEST_OF_NEGATIVE_WIDTH_HEIGHT_OR_DEPTH
9878 gl.textureSubImage2D(m_to_2D, 0, 0, 0, -1, s_reference_height, s_reference_format, s_reference_type,
9880 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage2D", "width is less than 0.");
9882 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, -1, s_reference_format, s_reference_type,
9884 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage2D", "height is less than 0.");
9888 /* Check that INVALID_OPERATION is generated by TextureSubImage2D if type
9889 is one of UNSIGNED_BYTE_3_3_2, UNSIGNED_BYTE_2_3_3_REV,
9890 UNSIGNED_SHORT_5_6_5, or UNSIGNED_SHORT_5_6_5_REV and format is not RGB. */
9892 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9893 GL_UNSIGNED_BYTE_3_3_2, s_reference);
9894 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9895 "type is UNSIGNED_BYTE_3_3_2 and format is not RGB.");
9897 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9898 GL_UNSIGNED_BYTE_2_3_3_REV, s_reference);
9899 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9900 "type is UNSIGNED_BYTE_2_3_3_REV and format is not RGB.");
9902 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9903 GL_UNSIGNED_SHORT_5_6_5, s_reference);
9904 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9905 "type is UNSIGNED_SHORT_5_6_5 and format is not RGB.");
9907 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9908 GL_UNSIGNED_SHORT_5_6_5_REV, s_reference);
9909 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9910 "type is UNSIGNED_SHORT_5_6_5_REV and format is not RGB.");
9913 /* Check that INVALID_OPERATION is generated by TextureSubImage2D if type
9914 is one of UNSIGNED_SHORT_4_4_4_4, UNSIGNED_SHORT_4_4_4_4_REV,
9915 UNSIGNED_SHORT_5_5_5_1, UNSIGNED_SHORT_1_5_5_5_REV,
9916 UNSIGNED_INT_8_8_8_8, UNSIGNED_INT_8_8_8_8_REV, UNSIGNED_INT_10_10_10_2,
9917 or UNSIGNED_INT_2_10_10_10_REV and format is neither RGBA nor BGRA. */
9919 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9920 GL_UNSIGNED_SHORT_4_4_4_4, s_reference);
9921 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9922 "type is UNSIGNED_SHORT_4_4_4_4 and format is neither RGBA nor BGRA.");
9924 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9925 GL_UNSIGNED_SHORT_4_4_4_4_REV, s_reference);
9926 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9927 "type is UNSIGNED_SHORT_4_4_4_4_REV and format is neither RGBA nor BGRA.");
9929 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9930 GL_UNSIGNED_SHORT_5_5_5_1, s_reference);
9931 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9932 "type is UNSIGNED_SHORT_5_5_5_1 and format is neither RGBA nor BGRA.");
9934 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9935 GL_UNSIGNED_SHORT_1_5_5_5_REV, s_reference);
9936 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9937 "type is UNSIGNED_SHORT_1_5_5_5_REV and format is neither RGBA nor BGRA.");
9939 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9940 GL_UNSIGNED_INT_8_8_8_8, s_reference);
9941 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9942 "type is UNSIGNED_INT_8_8_8_8 and format is neither RGBA nor BGRA.");
9944 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9945 GL_UNSIGNED_INT_8_8_8_8_REV, s_reference);
9946 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9947 "type is UNSIGNED_INT_8_8_8_8_REV and format is neither RGBA nor BGRA.");
9949 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9950 GL_UNSIGNED_INT_10_10_10_2, s_reference);
9951 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9952 "type is UNSIGNED_INT_10_10_10_2 and format is neither RGBA nor BGRA.");
9954 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9955 GL_UNSIGNED_INT_2_10_10_10_REV, s_reference);
9956 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9957 "type is UNSIGNED_INT_2_10_10_10_REV and format is neither RGBA nor BGRA.");
9960 /* Check that INVALID_OPERATION is generated by TextureSubImage2D if a
9961 non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
9962 and the buffer object's data store is currently mapped. */
9964 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
9965 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9967 gl.mapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_READ_WRITE);
9969 if (GL_NO_ERROR == gl.getError())
9971 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9972 s_reference_type, NULL);
9973 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9974 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and "
9975 "the buffer object's data store is currently mapped.");
9977 gl.unmapBuffer(GL_PIXEL_UNPACK_BUFFER);
9978 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9980 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
9981 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9985 /* Check that INVALID_OPERATION is generated by TextureSubImage2D if a
9986 non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
9987 and the data would be unpacked from the buffer object such that the
9988 memory reads required would exceed the data store size. */
9990 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
9991 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9993 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9994 s_reference_type, (glw::GLubyte*)NULL + s_reference_size * 2);
9995 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9996 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and the "
9997 "data would be unpacked from the buffer object such that the memory reads required "
9998 "would exceed the data store size.");
10000 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10001 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10004 /* Check that INVALID_OPERATION is generated by TextureSubImage2D if a
10005 non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
10006 and pixels is not evenly divisible into the number of bytes needed to
10007 store in memory a datum indicated by type. */
10009 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
10010 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10012 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
10013 s_reference_type, (glw::GLubyte*)NULL + 1);
10014 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
10015 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and pixels "
10016 "is not evenly divisible into the number of bytes needed to store in memory a datum "
10017 "indicated by type.");
10019 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10020 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10026 /** @brief Test (negative) of TextureSubImage3D
10028 * @return Test result.
10030 bool SubImageErrorsTest::Test3D()
10032 /* Shortcut for GL functionality. */
10033 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
10038 /* Check that INVALID_OPERATION is generated by TextureSubImage3D if
10039 texture is not the name of an existing texture object. */
10041 gl.textureSubImage3D(m_to_invalid, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10042 s_reference_format, s_reference_type, s_reference);
10043 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10044 "texture is not the name of an existing texture object.");
10047 /* Check that INVALID_ENUM is generated by TextureSubImage3D if format is
10048 not an accepted format constant. */
10050 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10051 m_format_invalid, s_reference_type, s_reference);
10052 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureSubImage3D",
10053 "format is not an accepted format constant.");
10056 /* Check that INVALID_ENUM is generated by TextureSubImage3D if type is not
10057 an accepted type constant. */
10059 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10060 s_reference_format, m_type_invalid, s_reference);
10061 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureSubImage3D",
10062 "type is not an accepted type constant.");
10065 /* Check that INVALID_VALUE is generated by TextureSubImage3D if level is
10068 gl.textureSubImage3D(m_to_3D, -1, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10069 s_reference_format, s_reference_type, s_reference);
10070 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage3D", "level is less than 0.");
10073 /* Check that INVALID_VALUE may be generated by TextureSubImage1D if level
10074 is greater than log2 max, where max is the returned value of
10075 MAX_TEXTURE_SIZE. */
10077 gl.textureSubImage3D(m_to_3D, m_max_texture_size, 0, 0, 0, s_reference_width, s_reference_height,
10078 s_reference_depth, s_reference_format, s_reference_type, s_reference);
10080 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage3D",
10081 "level is greater than log2 max, where max is the returned value of MAX_TEXTURE_SIZE.");
10084 /* Check that INVALID_VALUE is generated by TextureSubImage3D if
10085 xoffset<-b, (xoffset+width)>(w-b), yoffset<-b, or
10086 (yoffset+height)>(h-b), or zoffset<-b, or (zoffset+depth)>(d-b), where w
10087 is the TEXTURE_WIDTH, h is the TEXTURE_HEIGHT, d is the TEXTURE_DEPTH
10088 and b is the border width of the texture image being modified. Note
10089 that w, h, and d include twice the border width. */
10091 gl.textureSubImage3D(m_to_3D, 0, -1, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10092 s_reference_format, s_reference_type, s_reference);
10093 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage3D",
10094 "xoffset<-b, where b is the width of the TEXTURE_BORDER.");
10096 gl.textureSubImage3D(m_to_3D, 0, 1, 0, 0, s_reference_width + 1, s_reference_height, s_reference_depth,
10097 s_reference_format, s_reference_type, s_reference);
10098 is_ok &= CheckErrorAndLog(
10099 m_context, GL_INVALID_VALUE, "glTextureSubImage3D",
10100 "(xoffset+width)>(w-b), where w is the TEXTURE_WIDTH, b is the width of the TEXTURE_BORDER.");
10102 gl.textureSubImage3D(m_to_3D, 0, 0, -1, 0, s_reference_width, s_reference_height, s_reference_depth,
10103 s_reference_format, s_reference_type, s_reference);
10104 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage3D",
10105 "yoffset<-b, where b is the width of the TEXTURE_BORDER.");
10107 gl.textureSubImage3D(m_to_3D, 0, 0, 1, 0, s_reference_width + 1, s_reference_height, s_reference_depth,
10108 s_reference_format, s_reference_type, s_reference);
10109 is_ok &= CheckErrorAndLog(
10110 m_context, GL_INVALID_VALUE, "glTextureSubImage3D",
10111 "(yoffset+height)>(h-b), where h is the TEXTURE_HEIGHT, b is the width of the TEXTURE_BORDER.");
10113 gl.textureSubImage3D(m_to_3D, 0, 0, 0, -1, s_reference_width, s_reference_height, s_reference_depth,
10114 s_reference_format, s_reference_type, s_reference);
10115 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage3D",
10116 "zoffset<-b, where b is the depth of the TEXTURE_BORDER.");
10118 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 1, s_reference_width + 1, s_reference_height, s_reference_depth,
10119 s_reference_format, s_reference_type, s_reference);
10120 is_ok &= CheckErrorAndLog(
10121 m_context, GL_INVALID_VALUE, "glTextureSubImage3D",
10122 "(zoffset+width)>(d-b), where d is the TEXTURE_DEPTH, b is the width of the TEXTURE_BORDER.");
10125 /*Check that INVALID_VALUE is generated by TextureSubImage3D if width or height or depth is less than 0. */
10127 #ifndef TURN_OFF_SUB_IMAGE_ERRORS_TEST_OF_NEGATIVE_WIDTH_HEIGHT_OR_DEPTH
10128 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, -1, s_reference_height, s_reference_depth, s_reference_format,
10129 s_reference_type, s_reference);
10130 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage1D", "width is less than 0.");
10132 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, -1, s_reference_depth, s_reference_format,
10133 s_reference_type, s_reference);
10134 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage1D", "height is less than 0.");
10136 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, -1, s_reference_format,
10137 s_reference_type, s_reference);
10138 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage1D", "depth is less than 0.");
10142 /* Check that INVALID_OPERATION is generated by TextureSubImage3D if type
10143 is one of UNSIGNED_BYTE_3_3_2, UNSIGNED_BYTE_2_3_3_REV,
10144 UNSIGNED_SHORT_5_6_5, or UNSIGNED_SHORT_5_6_5_REV and format is not RGB. */
10146 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10147 s_reference_format, GL_UNSIGNED_BYTE_3_3_2, s_reference);
10148 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10149 "type is UNSIGNED_BYTE_3_3_2 and format is not RGB.");
10151 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10152 s_reference_format, GL_UNSIGNED_BYTE_2_3_3_REV, s_reference);
10153 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10154 "type is UNSIGNED_BYTE_2_3_3_REV and format is not RGB.");
10156 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10157 s_reference_format, GL_UNSIGNED_SHORT_5_6_5, s_reference);
10158 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10159 "type is UNSIGNED_SHORT_5_6_5 and format is not RGB.");
10161 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10162 s_reference_format, GL_UNSIGNED_SHORT_5_6_5_REV, s_reference);
10163 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10164 "type is UNSIGNED_SHORT_5_6_5_REV and format is not RGB.");
10167 /* Check that INVALID_OPERATION is generated by TextureSubImage3D if type
10168 is one of UNSIGNED_SHORT_4_4_4_4, UNSIGNED_SHORT_4_4_4_4_REV,
10169 UNSIGNED_SHORT_5_5_5_1, UNSIGNED_SHORT_1_5_5_5_REV,
10170 UNSIGNED_INT_8_8_8_8, UNSIGNED_INT_8_8_8_8_REV, UNSIGNED_INT_10_10_10_2,
10171 or UNSIGNED_INT_2_10_10_10_REV and format is neither RGBA nor BGRA. */
10173 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10174 s_reference_format, GL_UNSIGNED_SHORT_4_4_4_4, s_reference);
10175 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10176 "type is UNSIGNED_SHORT_4_4_4_4 and format is neither RGBA nor BGRA.");
10178 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10179 s_reference_format, GL_UNSIGNED_SHORT_4_4_4_4_REV, s_reference);
10180 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10181 "type is UNSIGNED_SHORT_4_4_4_4_REV and format is neither RGBA nor BGRA.");
10183 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10184 s_reference_format, GL_UNSIGNED_SHORT_5_5_5_1, s_reference);
10185 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10186 "type is UNSIGNED_SHORT_5_5_5_1 and format is neither RGBA nor BGRA.");
10188 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10189 s_reference_format, GL_UNSIGNED_SHORT_1_5_5_5_REV, s_reference);
10190 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10191 "type is UNSIGNED_SHORT_1_5_5_5_REV and format is neither RGBA nor BGRA.");
10193 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10194 s_reference_format, GL_UNSIGNED_INT_8_8_8_8, s_reference);
10195 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10196 "type is UNSIGNED_INT_8_8_8_8 and format is neither RGBA nor BGRA.");
10198 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10199 s_reference_format, GL_UNSIGNED_INT_8_8_8_8_REV, s_reference);
10200 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10201 "type is UNSIGNED_INT_8_8_8_8_REV and format is neither RGBA nor BGRA.");
10203 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10204 s_reference_format, GL_UNSIGNED_INT_10_10_10_2, s_reference);
10205 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10206 "type is UNSIGNED_INT_10_10_10_2 and format is neither RGBA nor BGRA.");
10208 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10209 s_reference_format, GL_UNSIGNED_INT_2_10_10_10_REV, s_reference);
10210 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10211 "type is UNSIGNED_INT_2_10_10_10_REV and format is neither RGBA nor BGRA.");
10214 /* Check that INVALID_OPERATION is generated by TextureSubImage3D if a
10215 non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
10216 and the buffer object's data store is currently mapped. */
10218 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
10219 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10221 gl.mapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_READ_WRITE);
10223 if (GL_NO_ERROR == gl.getError())
10225 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10226 s_reference_format, s_reference_type, NULL);
10227 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10228 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and "
10229 "the buffer object's data store is currently mapped.");
10231 gl.unmapBuffer(GL_PIXEL_UNPACK_BUFFER);
10232 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10234 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10235 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10239 /* Check that INVALID_OPERATION is generated by TextureSubImage3D if a
10240 non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
10241 and the data would be unpacked from the buffer object such that the
10242 memory reads required would exceed the data store size. */
10244 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
10245 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10247 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10248 s_reference_format, s_reference_type, (glw::GLubyte*)NULL + s_reference_size * 2);
10249 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10250 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and the "
10251 "data would be unpacked from the buffer object such that the memory reads required "
10252 "would exceed the data store size.");
10254 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10255 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10258 /* Check that INVALID_OPERATION is generated by TextureSubImage3D if a
10259 non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
10260 and pixels is not evenly divisible into the number of bytes needed to
10261 store in memory a datum indicated by type. */
10263 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
10264 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10266 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10267 s_reference_format, s_reference_type, (glw::GLubyte*)NULL + 1);
10268 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10269 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and pixels "
10270 "is not evenly divisible into the number of bytes needed to store in memory a datum "
10271 "indicated by type.");
10273 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10274 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10280 /** @brief Test (negative) of TextureSubImage1DCompressed
10282 * @return Test result.
10284 bool SubImageErrorsTest::Test1DCompressed()
10286 /* Shortcut for GL functionality. */
10287 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
10292 /* Do tests only if compressed 1D textures are supported. */
10293 if (DE_NULL != m_reference_compressed_1D)
10295 /* Check that INVALID_OPERATION is generated by CompressedTextureSubImage1D
10296 if texture is not the name of an existing texture object. */
10298 gl.compressedTextureSubImage1D(m_to_invalid, 0, 0, s_reference_width, m_reference_compressed_1D_format,
10299 m_reference_compressed_1D_size, m_reference_compressed_1D);
10300 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage1D",
10301 "texture is not the name of an existing texture object.");
10304 /* Check that INVALID_ENUM is generated by CompressedTextureSubImage1D if
10305 internalformat is not one of the generic compressed internal formats:
10306 COMPRESSED_RED, COMPRESSED_RG, COMPRESSED_RGB, COMPRESSED_RGBA.
10307 COMPRESSED_SRGB, or COMPRESSED_SRGB_ALPHA. */
10309 /* GL_COMPRESSED_RG_RGTC2 is not 1D as specification says. */
10310 gl.compressedTextureSubImage1D(m_to_1D_compressed, 0, 0, s_reference_width, GL_COMPRESSED_RG_RGTC2,
10311 m_reference_compressed_1D_size, m_reference_compressed_1D);
10312 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glCompressedTextureSubImage1D",
10313 "internalformat is of the generic compressed internal formats: COMPRESSED_RED, "
10314 "COMPRESSED_RG, COMPRESSED_RGB, COMPRESSED_RGBA. COMPRESSED_SRGB, or "
10315 "COMPRESSED_SRGB_ALPHA.");
10318 /* Check that INVALID_OPERATION is generated if format does not match the
10319 internal format of the texture image being modified, since these
10320 commands do not provide for image format conversion. */
10322 gl.compressedTextureSubImage1D(m_to_1D_compressed, 0, 0, s_reference_width,
10323 m_not_matching_compressed_1D_format, m_not_matching_compressed_1D_size,
10324 m_reference_compressed_1D);
10325 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage1D",
10326 "format does not match the internal format of the texture image being modified, "
10327 "since these commands do not provide for image format conversion.");
10330 /* Check that INVALID_VALUE is generated by CompressedTextureSubImage1D if
10331 imageSize is not consistent with the format, dimensions, and contents of
10332 the specified compressed image data. */
10334 gl.compressedTextureSubImage1D(m_to_1D_compressed, 0, 0, s_reference_width,
10335 m_reference_compressed_1D_format, m_reference_compressed_1D_size - 1,
10336 m_reference_compressed_1D);
10337 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCompressedTextureSubImage1D",
10338 "imageSize is not consistent with the format, dimensions, and contents of the "
10339 "specified compressed image data.");
10342 /* Check that INVALID_OPERATION is generated by CompressedTextureSubImage1D
10343 if a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER
10344 target and the buffer object's data store is currently mapped. */
10346 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
10347 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10349 gl.mapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_READ_WRITE);
10351 if (GL_NO_ERROR == gl.getError())
10353 gl.compressedTextureSubImage1D(m_to_1D_compressed, 0, 0, s_reference_width,
10354 m_reference_compressed_1D_format, m_reference_compressed_1D_size, NULL);
10355 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage1D",
10356 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target "
10357 "and the buffer object's data store is currently mapped.");
10359 gl.unmapBuffer(GL_PIXEL_UNPACK_BUFFER);
10360 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10362 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10363 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10367 /* Check that INVALID_OPERATION is generated by CompressedTextureSubImage1D
10368 if a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER
10369 target and the data would be unpacked from the buffer object such that
10370 the memory reads required would exceed the data store size. */
10372 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
10373 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10375 gl.compressedTextureSubImage1D(m_to_1D_compressed, 0, 0, s_reference_width,
10376 m_reference_compressed_1D_format, m_reference_compressed_1D_size,
10377 (glw::GLubyte*)NULL + s_reference_size * 2);
10378 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage1D",
10379 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and "
10380 "the buffer object's data store is currently mapped.");
10382 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10383 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10390 /** @brief Test (negative) of TextureSubImage2DCompressed
10392 * @return Test result.
10394 bool SubImageErrorsTest::Test2DCompressed()
10396 /* Shortcut for GL functionality. */
10397 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
10402 /* Do tests only if compressed 2D textures are supported. */
10403 if (DE_NULL != m_reference_compressed_2D)
10405 /* Check that INVALID_OPERATION is generated by CompressedTextureSubImage2D
10406 if texture is not the name of an existing texture object. */
10408 gl.compressedTextureSubImage2D(m_to_invalid, 0, 0, 0, s_reference_width, s_reference_height,
10409 m_reference_compressed_2D_format, m_reference_compressed_2D_size,
10410 m_reference_compressed_2D);
10411 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage2D",
10412 "texture is not the name of an existing texture object.");
10415 /* Check that INVALID_ENUM is generated by CompressedTextureSubImage2D if
10416 internalformat is of the generic compressed internal formats:
10417 COMPRESSED_RED, COMPRESSED_RG, COMPRESSED_RGB, COMPRESSED_RGBA.
10418 COMPRESSED_SRGB, or COMPRESSED_SRGB_ALPHA. */
10420 gl.compressedTextureSubImage2D(m_to_2D_compressed, 0, 0, 0, s_reference_width, s_reference_height,
10421 GL_COMPRESSED_RG, m_reference_compressed_2D_size, m_reference_compressed_2D);
10422 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glCompressedTextureSubImage2D",
10423 "internalformat is of the generic compressed internal formats: COMPRESSED_RED, "
10424 "COMPRESSED_RG, COMPRESSED_RGB, COMPRESSED_RGBA. COMPRESSED_SRGB, or "
10425 "COMPRESSED_SRGB_ALPHA.");
10428 /* Check that INVALID_OPERATION is generated if format does not match the
10429 internal format of the texture image being modified, since these
10430 commands do not provide for image format conversion. */
10432 gl.compressedTextureSubImage2D(m_to_2D_compressed, 0, 0, 0, s_reference_width, s_reference_height,
10433 m_not_matching_compressed_2D_format, m_not_matching_compressed_2D_size,
10434 m_reference_compressed_2D);
10435 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage2D",
10436 "format does not match the internal format of the texture image being modified, "
10437 "since these commands do not provide for image format conversion.");
10440 /* Check that INVALID_VALUE is generated by CompressedTextureSubImage2D if
10441 imageSize is not consistent with the format, dimensions, and contents of
10442 the specified compressed image data. */
10444 gl.compressedTextureSubImage2D(m_to_2D_compressed, 0, 0, 0, s_reference_width, s_reference_height,
10445 m_reference_compressed_2D_format, m_reference_compressed_2D_size - 1,
10446 m_reference_compressed_2D);
10447 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCompressedTextureSubImage2D",
10448 "imageSize is not consistent with the format, dimensions, and contents of the "
10449 "specified compressed image data.");
10452 /* Check that INVALID_OPERATION is generated by CompressedTextureSubImage2D
10453 if a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER
10454 target and the buffer object's data store is currently mapped. */
10456 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
10457 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10459 gl.mapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_READ_WRITE);
10461 if (GL_NO_ERROR == gl.getError())
10463 gl.compressedTextureSubImage2D(m_to_2D_compressed, 0, 0, 0, s_reference_width, s_reference_height,
10464 m_reference_compressed_2D_format, m_reference_compressed_2D_size, NULL);
10465 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage2D",
10466 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target "
10467 "and the buffer object's data store is currently mapped.");
10469 gl.unmapBuffer(GL_PIXEL_UNPACK_BUFFER);
10470 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10472 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10473 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10477 /* Check that INVALID_OPERATION is generated by CompressedTextureSubImage2D
10478 if a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER
10479 target and the data would be unpacked from the buffer object such that
10480 the memory reads required would exceed the data store size. */
10482 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
10483 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10485 gl.compressedTextureSubImage2D(m_to_2D_compressed, 0, 0, 0, s_reference_width, s_reference_height,
10486 m_reference_compressed_2D_format, m_reference_compressed_2D_size,
10487 (glw::GLubyte*)NULL + s_reference_size * 2);
10488 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage2D",
10489 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and "
10490 "the buffer object's data store is currently mapped.");
10492 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10493 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10496 /* Check that INVALID_OPERATION is generated by CompressedTextureSubImage2D
10497 if the effective target is TEXTURE_RECTANGLE. */
10499 m_reference_compressed_rectangle) /* Do test only if rectangle compressed texture is supported by the implementation. */
10501 gl.compressedTextureSubImage2D(m_to_rectangle_compressed, 0, 0, 0, s_reference_width, s_reference_height,
10502 m_reference_compressed_rectangle_format,
10503 m_reference_compressed_rectangle_size, m_reference_compressed_rectangle);
10505 if (m_context.getContextInfo().isExtensionSupported("GL_NV_texture_rectangle_compressed"))
10507 is_ok &= CheckErrorAndLog(m_context, GL_NO_ERROR, "glCompressedTextureSubImage2D",
10508 "a rectangle texture object is used with this function.");
10512 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage2D",
10513 "a rectangle texture object is used with this function.");
10521 /** @brief Test (negative) of TextureSubImage3DCompressed
10523 * @return Test result.
10525 bool SubImageErrorsTest::Test3DCompressed()
10527 /* Shortcut for GL functionality. */
10528 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
10533 /* Do tests only if compressed 3D textures are supported. */
10534 if (DE_NULL != m_reference_compressed_3D)
10536 /* Check that INVALID_OPERATION is generated by CompressedTextureSubImage3D
10537 if texture is not the name of an existing texture object. */
10539 gl.compressedTextureSubImage3D(m_to_invalid, 0, 0, 0, 0, s_reference_width, s_reference_height,
10540 s_reference_depth, m_reference_compressed_3D_format,
10541 m_reference_compressed_3D_size, m_reference_compressed_3D);
10542 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage3D",
10543 "texture is not the name of an existing texture object.");
10546 /* Check that INVALID_ENUM is generated by CompressedTextureSubImage3D if
10547 internalformat is of the generic compressed internal formats:
10548 COMPRESSED_RED, COMPRESSED_RG, COMPRESSED_RGB, COMPRESSED_RGBA.
10549 COMPRESSED_SRGB, or COMPRESSED_SRGB_ALPHA. */
10551 gl.compressedTextureSubImage3D(m_to_3D_compressed, 0, 0, 0, 0, s_reference_width, s_reference_height,
10552 s_reference_depth, GL_COMPRESSED_RG, m_reference_compressed_3D_size,
10553 m_reference_compressed_3D);
10554 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glCompressedTextureSubImage3D",
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.compressedTextureSubImage3D(m_to_3D_compressed, 0, 0, 0, 0, s_reference_width, s_reference_height,
10565 s_reference_depth, m_not_matching_compressed_3D_format,
10566 m_not_matching_compressed_3D_size, m_reference_compressed_3D);
10567 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage3D",
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 CompressedTextureSubImage3D if
10573 imageSize is not consistent with the format, dimensions, and contents of
10574 the specified compressed image data. */
10576 gl.compressedTextureSubImage3D(m_to_3D_compressed, 0, 0, 0, 0, s_reference_width, s_reference_height,
10577 s_reference_depth, m_reference_compressed_3D_format,
10578 m_reference_compressed_3D_size - 1, m_reference_compressed_3D);
10579 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCompressedTextureSubImage3D",
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 CompressedTextureSubImage3D
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.compressedTextureSubImage3D(m_to_3D_compressed, 0, 0, 0, 0, s_reference_width, s_reference_height,
10596 s_reference_depth, m_reference_compressed_3D_format,
10597 m_reference_compressed_3D_size, NULL);
10598 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage3D",
10599 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target "
10600 "and the buffer object's data store is currently mapped.");
10602 gl.unmapBuffer(GL_PIXEL_UNPACK_BUFFER);
10603 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10605 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10606 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10610 /* Check that INVALID_OPERATION is generated by CompressedTextureSubImage3D
10611 if a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER
10612 target and the data would be unpacked from the buffer object such that
10613 the memory reads required would exceed the data store size. */
10615 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
10616 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10618 gl.compressedTextureSubImage3D(m_to_3D_compressed, 0, 0, 0, 0, s_reference_width, s_reference_height,
10619 s_reference_depth, m_reference_compressed_3D_format,
10620 m_reference_compressed_3D_size, (glw::GLubyte*)NULL + s_reference_size * 2);
10621 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage3D",
10622 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and "
10623 "the buffer object's data store is currently mapped.");
10625 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10626 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10633 /** @brief Clean GL objects, test variables and GL errors.
10635 void SubImageErrorsTest::Clean()
10637 /* Shortcut for GL functionality. */
10638 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
10643 gl.deleteTextures(1, &m_to_1D_empty);
10650 gl.deleteTextures(1, &m_to_2D_empty);
10657 gl.deleteTextures(1, &m_to_3D_empty);
10664 gl.deleteTextures(1, &m_to_1D);
10671 gl.deleteTextures(1, &m_to_2D);
10678 gl.deleteTextures(1, &m_to_3D);
10683 if (m_to_1D_compressed)
10685 gl.deleteTextures(1, &m_to_1D_compressed);
10687 m_to_1D_compressed = 0;
10690 if (m_to_2D_compressed)
10692 gl.deleteTextures(1, &m_to_2D_compressed);
10694 m_to_2D_compressed = 0;
10697 if (m_to_3D_compressed)
10699 gl.deleteTextures(1, &m_to_3D_compressed);
10701 m_to_3D_compressed = 0;
10704 if (m_to_rectangle_compressed)
10706 gl.deleteTextures(1, &m_to_rectangle_compressed);
10708 m_to_rectangle_compressed = 0;
10713 gl.deleteBuffers(1, &m_bo);
10719 m_format_invalid = 0;
10720 m_type_invalid = 0;
10721 m_max_texture_size = 1;
10723 if (DE_NULL != m_reference_compressed_1D)
10725 delete[] m_reference_compressed_1D;
10727 m_reference_compressed_1D = NULL;
10730 if (DE_NULL != m_reference_compressed_2D)
10732 delete[] m_reference_compressed_2D;
10734 m_reference_compressed_2D = NULL;
10737 if (DE_NULL != m_reference_compressed_3D)
10739 delete[] m_reference_compressed_3D;
10741 m_reference_compressed_3D = NULL;
10744 if (DE_NULL != m_reference_compressed_rectangle)
10746 delete[] m_reference_compressed_rectangle;
10748 m_reference_compressed_rectangle = NULL;
10751 m_reference_compressed_1D_format = 0;
10752 m_reference_compressed_2D_format = 0;
10753 m_reference_compressed_3D_format = 0;
10754 m_reference_compressed_rectangle_format = 0;
10755 m_reference_compressed_1D_size = 0;
10756 m_reference_compressed_2D_size = 0;
10757 m_reference_compressed_3D_size = 0;
10758 m_reference_compressed_rectangle_size = 0;
10759 m_not_matching_compressed_1D_format = 0;
10760 m_not_matching_compressed_1D_size = 0;
10761 m_not_matching_compressed_2D_format = 0;
10762 m_not_matching_compressed_2D_size = 0;
10763 m_not_matching_compressed_3D_format = 0;
10764 m_not_matching_compressed_3D_size = 0;
10766 while (GL_NO_ERROR != gl.getError())
10770 /** Reference data */
10771 const glw::GLushort SubImageErrorsTest::s_reference[] = {
10772 0x0, 0x0, 0x0, 0xff, 0x7f, 0x7f, 0x7f, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff,
10773 0x88, 0x0, 0x15, 0xff, 0xed, 0x1c, 0x24, 0xff, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x0, 0xff,
10774 0xc8, 0xbf, 0xe7, 0xff, 0x70, 0x92, 0xbe, 0xff, 0x99, 0xd9, 0xea, 0xff, 0xb5, 0xe6, 0x1d, 0xff,
10775 0xa3, 0x49, 0xa4, 0xff, 0x3f, 0x48, 0xcc, 0xff, 0x0, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0xff,
10777 0x0, 0x0, 0x0, 0xff, 0x7f, 0x7f, 0x7f, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff,
10778 0x88, 0x0, 0x15, 0xff, 0xed, 0x1c, 0x24, 0xff, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x0, 0xff,
10779 0xc8, 0xbf, 0xe7, 0xff, 0x70, 0x92, 0xbe, 0xff, 0x99, 0xd9, 0xea, 0xff, 0xb5, 0xe6, 0x1d, 0xff,
10780 0xa3, 0x49, 0xa4, 0xff, 0x3f, 0x48, 0xcc, 0xff, 0x0, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0xff,
10782 0x0, 0x0, 0x0, 0xff, 0x7f, 0x7f, 0x7f, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff,
10783 0x88, 0x0, 0x15, 0xff, 0xed, 0x1c, 0x24, 0xff, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x0, 0xff,
10784 0xc8, 0xbf, 0xe7, 0xff, 0x70, 0x92, 0xbe, 0xff, 0x99, 0xd9, 0xea, 0xff, 0xb5, 0xe6, 0x1d, 0xff,
10785 0xa3, 0x49, 0xa4, 0xff, 0x3f, 0x48, 0xcc, 0xff, 0x0, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0xff,
10787 0x0, 0x0, 0x0, 0xff, 0x7f, 0x7f, 0x7f, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff,
10788 0x88, 0x0, 0x15, 0xff, 0xed, 0x1c, 0x24, 0xff, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x0, 0xff,
10789 0xc8, 0xbf, 0xe7, 0xff, 0x70, 0x92, 0xbe, 0xff, 0x99, 0xd9, 0xea, 0xff, 0xb5, 0xe6, 0x1d, 0xff,
10790 0xa3, 0x49, 0xa4, 0xff, 0x3f, 0x48, 0xcc, 0xff, 0x0, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0xff
10793 /** Reference data parameters. */
10794 const glw::GLuint SubImageErrorsTest::s_reference_size = sizeof(s_reference);
10795 const glw::GLuint SubImageErrorsTest::s_reference_width = 4;
10796 const glw::GLuint SubImageErrorsTest::s_reference_height = 4;
10797 const glw::GLuint SubImageErrorsTest::s_reference_depth = 4;
10798 const glw::GLenum SubImageErrorsTest::s_reference_internalformat = GL_RG8;
10799 const glw::GLenum SubImageErrorsTest::s_reference_internalformat_compressed = GL_COMPRESSED_RG;
10800 const glw::GLenum SubImageErrorsTest::s_reference_format = GL_RG; /* !Must not be a RGB, RGBA, or BGRA */
10801 const glw::GLenum SubImageErrorsTest::s_reference_type = GL_UNSIGNED_SHORT;
10803 /******************************** Copy Errors Test Implementation ********************************/
10805 /** @brief Copy Errors Test constructor.
10807 * @param [in] context OpenGL context.
10809 CopyErrorsTest::CopyErrorsTest(deqp::Context& context)
10810 : deqp::TestCase(context, "textures_copy_errors", "Texture Copy Errors Test")
10813 , m_fbo_incomplete(0)
10821 /* Intentionally left blank. */
10824 /** @brief Iterate Copy Errors Test cases.
10826 * @return Iteration result.
10828 tcu::TestNode::IterateResult CopyErrorsTest::iterate()
10830 /* Get context setup. */
10831 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
10832 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
10834 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
10836 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
10841 /* Running tests. */
10843 bool is_error = false;
10862 /* Result's setup. */
10865 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
10871 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
10875 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
10882 /** @brief Prepare test's objects and values.
10884 void CopyErrorsTest::Prepare()
10886 /* Shortcut for GL functionality. */
10887 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
10889 /* Auxiliary objects setup. */
10892 gl.genFramebuffers(1, &m_fbo);
10893 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
10895 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
10896 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
10898 gl.createTextures(GL_TEXTURE_2D, 1, &m_to_src);
10899 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
10901 gl.textureStorage2D(m_to_src, 1, s_internalformat, s_width, s_height);
10902 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage2D has failed");
10904 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_to_src, 0);
10905 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferTexture1D call failed.");
10907 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
10912 gl.viewport(0, 0, s_width, s_height);
10913 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
10915 gl.clear(GL_COLOR_BUFFER_BIT);
10916 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear call failed.");
10918 /* Framebuffer Multisample. */
10919 gl.genFramebuffers(1, &m_fbo_ms);
10920 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
10922 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_ms);
10923 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
10925 gl.createTextures(GL_TEXTURE_2D_MULTISAMPLE, 1, &m_to_src_ms);
10926 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
10928 gl.textureStorage2DMultisample(m_to_src_ms, 1, s_internalformat, s_width, s_height, false);
10929 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage2DMultisample has failed");
10931 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, m_to_src_ms, 0);
10932 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferTexture1D call failed.");
10934 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
10939 gl.viewport(0, 0, s_width, s_height);
10940 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
10942 gl.clear(GL_COLOR_BUFFER_BIT);
10943 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear call failed.");
10945 /* Framebuffer Incomplete. */
10946 gl.createFramebuffers(1, &m_fbo_incomplete);
10947 GLU_EXPECT_NO_ERROR(gl.getError(), "glcreateFramebuffers call failed.");
10950 gl.createTextures(GL_TEXTURE_1D, 1, &m_to_1D_dst);
10951 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
10953 gl.textureStorage1D(m_to_1D_dst, 1, s_internalformat, s_width);
10954 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage2D has failed");
10957 gl.createTextures(GL_TEXTURE_2D, 1, &m_to_2D_dst);
10958 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
10960 gl.textureStorage2D(m_to_2D_dst, 1, s_internalformat, s_width, s_height);
10961 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage2D has failed");
10964 gl.createTextures(GL_TEXTURE_3D, 1, &m_to_3D_dst);
10965 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
10967 gl.textureStorage3D(m_to_3D_dst, 1, s_internalformat, s_width, s_height, s_depth);
10968 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage2D has failed");
10970 /* invalid texture object */
10971 while (gl.isTexture(++m_to_invalid))
10973 GLU_EXPECT_NO_ERROR(gl.getError(), "glIsTexture has failed");
10976 /** @brief Test (negative) of CopyTextureSubImage1D
10978 * @return Test result.
10980 bool CopyErrorsTest::Test1D()
10982 /* Shortcut for GL functionality. */
10983 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
10988 /* Bind framebuffer. */
10989 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_incomplete);
10990 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
10992 /* Check that INVALID_FRAMEBUFFER_OPERATION is generated by
10993 CopyTextureSubImage1D if the object bound to READ_FRAMEBUFFER_BINDING is
10994 not framebuffer complete. */
10996 gl.copyTextureSubImage1D(m_to_1D_dst, 0, 0, 0, 0, s_width);
10997 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_FRAMEBUFFER_OPERATION, "glCopyTextureSubImage1D",
10998 "the object bound to READ_FRAMEBUFFER_BINDING is not framebuffer complete.");
11001 /* Bind framebuffer. */
11002 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
11003 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11005 gl.readBuffer(GL_COLOR_ATTACHMENT0);
11006 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11008 /* Check that INVALID_OPERATION is generated by CopyTextureSubImage1D if
11009 texture is not the name of an existing texture object, or if the
11010 effective target of texture is not TEXTURE_1D. */
11012 gl.copyTextureSubImage1D(m_to_invalid, 0, 0, 0, 0, s_width);
11013 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage1D",
11014 "texture is not the name of an existing texture object.");
11016 gl.copyTextureSubImage1D(m_to_2D_dst, 0, 0, 0, 0, s_width);
11017 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage1D",
11018 "the effective target of texture is not TEXTURE_1D.");
11021 /* Check that INVALID_VALUE is generated by CopyTextureSubImage1D if level is less than 0. */
11023 gl.copyTextureSubImage1D(m_to_1D_dst, -1, 0, 0, 0, s_width);
11024 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage1D", "level is less than 0.");
11027 /* Check that INVALID_VALUE is generated by CopyTextureSubImage1D if
11028 xoffset<0, or (xoffset+width)>w, where w is the TEXTURE_WIDTH of the
11029 texture image being modified. */
11031 gl.copyTextureSubImage1D(m_to_1D_dst, 0, -1, 0, 0, s_width);
11032 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage1D", "xoffset<0.");
11034 gl.copyTextureSubImage1D(m_to_1D_dst, 0, 1, 0, 0, s_width);
11036 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage1D",
11037 "(xoffset+width)>w, where w is the TEXTURE_WIDTH of the texture image being modified.");
11040 /* Check that INVALID_OPERATION is generated by CopyTextureSubImage1D if
11041 the read buffer is NONE. */
11042 gl.readBuffer(GL_NONE);
11043 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11046 gl.copyTextureSubImage1D(m_to_1D_dst, 0, 0, 0, 0, s_width);
11048 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage1D", "the read buffer is NONE.");
11051 /* Bind multisample framebuffer. */
11052 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_ms);
11053 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11055 gl.readBuffer(GL_COLOR_ATTACHMENT0);
11056 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11058 /* Check that INVALID_OPERATION is generated by CopyTextureSubImage1D if
11059 the effective value of SAMPLE_BUFFERS for the read
11060 framebuffer is one. */
11062 gl.copyTextureSubImage1D(m_to_1D_dst, 0, 0, 0, 0, s_width);
11063 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage1D",
11064 "the effective value of SAMPLE_BUFFERS for the read framebuffer is one.");
11070 /** @brief Test (negative) of CopyTextureSubImage2D
11072 * @return Test result.
11074 bool CopyErrorsTest::Test2D()
11076 /* Shortcut for GL functionality. */
11077 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
11082 /* Bind framebuffer. */
11083 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_incomplete);
11084 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11086 /* Check that INVALID_FRAMEBUFFER_OPERATION is generated by
11087 CopyTextureSubImage2D if the object bound to READ_FRAMEBUFFER_BINDING is
11088 not framebuffer complete. */
11090 gl.copyTextureSubImage2D(m_to_2D_dst, 0, 0, 0, 0, 0, s_width, s_height);
11091 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_FRAMEBUFFER_OPERATION, "glCopyTextureSubImage2D",
11092 "the object bound to READ_FRAMEBUFFER_BINDING is not framebuffer complete.");
11095 /* Bind framebuffer. */
11096 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
11097 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11099 gl.readBuffer(GL_COLOR_ATTACHMENT0);
11100 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11102 /* Check that INVALID_OPERATION is generated by CopyTextureSubImage2D if
11103 texture is not the name of an existing texture object, or if the
11104 effective target of texture is not TEXTURE_2D. */
11106 gl.copyTextureSubImage2D(m_to_invalid, 0, 0, 0, 0, 0, s_width, s_height);
11107 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage2D",
11108 "texture is not the name of an existing texture object.");
11110 gl.copyTextureSubImage2D(m_to_1D_dst, 0, 0, 0, 0, 0, s_width, s_height);
11111 is_ok &= CheckErrorAndLog(
11112 m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage2D",
11113 "the effective target of does not correspond to one of the texture targets supported by the function..");
11116 /* Check that INVALID_VALUE is generated by CopyTextureSubImage2D if level is less than 0. */
11118 gl.copyTextureSubImage2D(m_to_2D_dst, -1, 0, 0, 0, 0, s_width, s_height);
11119 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage2D", "level is less than 0.");
11122 /* Check that INVALID_VALUE is generated by CopyTextureSubImage2D if
11123 xoffset<0, (xoffset+width)>w, yoffset<0, or (yoffset+height)>0, where w
11124 is the TEXTURE_WIDTH, h is the TEXTURE_HEIGHT and of the texture image
11127 gl.copyTextureSubImage2D(m_to_2D_dst, 0, -1, 0, 0, 0, s_width, s_height);
11128 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage2D", "xoffset<0.");
11130 gl.copyTextureSubImage2D(m_to_2D_dst, 0, 1, 0, 0, 0, s_width, s_height);
11132 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage2D",
11133 "(xoffset+width)>w, where w is the TEXTURE_WIDTH of the texture image being modified.");
11135 gl.copyTextureSubImage2D(m_to_2D_dst, 0, 0, -1, 0, 0, s_width, s_height);
11136 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage2D", "yoffset<0.");
11138 gl.copyTextureSubImage2D(m_to_2D_dst, 0, 0, 1, 0, 0, s_width, s_height);
11140 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage2D",
11141 "(yoffset+height)>h, where h is the TEXTURE_HEIGHT of the texture image being modified.");
11144 /* Check that INVALID_OPERATION is generated by CopyTextureSubImage2D if
11145 the read buffer is NONE. */
11146 gl.readBuffer(GL_NONE);
11147 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11150 gl.copyTextureSubImage2D(m_to_2D_dst, 0, 0, 0, 0, 0, s_width, s_height);
11152 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage2D", "the read buffer is NONE.");
11155 /* Bind multisample framebuffer. */
11156 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_ms);
11157 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11159 gl.readBuffer(GL_COLOR_ATTACHMENT0);
11160 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11162 /* Check that INVALID_OPERATION is generated by CopyTextureSubImage2D if
11163 the effective value of SAMPLE_BUFFERS for the read
11164 framebuffer is one. */
11166 gl.copyTextureSubImage2D(m_to_2D_dst, 0, 0, 0, 0, 0, s_width, s_height);
11167 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage2D",
11168 "the effective value of SAMPLE_BUFFERS for the read framebuffer is one.");
11174 /** @brief Test (negative) of CopyTextureSubImage3D
11176 * @return Test result.
11178 bool CopyErrorsTest::Test3D()
11180 /* Shortcut for GL functionality. */
11181 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
11186 /* Bind framebuffer. */
11187 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_incomplete);
11188 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11190 /* Check that INVALID_FRAMEBUFFER_OPERATION is generated by
11191 CopyTextureSubImage3D if the object bound to READ_FRAMEBUFFER_BINDING is
11192 not framebuffer complete. */
11194 gl.copyTextureSubImage3D(m_to_3D_dst, 0, 0, 0, 0, 0, 0, s_width, s_height);
11195 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_FRAMEBUFFER_OPERATION, "glCopyTextureSubImage3D",
11196 "the object bound to READ_FRAMEBUFFER_BINDING is not framebuffer complete.");
11199 /* Bind framebuffer. */
11200 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
11201 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11203 gl.readBuffer(GL_COLOR_ATTACHMENT0);
11204 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11206 /* Check that INVALID_OPERATION is generated by CopyTextureSubImage3D if
11207 texture is not the name of an existing texture object, or if the
11208 effective target of texture is not supported by the function. */
11210 gl.copyTextureSubImage3D(m_to_invalid, 0, 0, 0, 0, 0, 0, s_width, s_height);
11211 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage3D",
11212 "texture is not the name of an existing texture object.");
11214 gl.copyTextureSubImage3D(m_to_1D_dst, 0, 0, 0, 0, 0, 0, s_width, s_height);
11215 is_ok &= CheckErrorAndLog(
11216 m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage3D",
11217 "the effective target of does not correspond to one of the texture targets supported by the function..");
11220 /* Check that INVALID_VALUE is generated by CopyTextureSubImage3D if level is less than 0. */
11222 gl.copyTextureSubImage3D(m_to_3D_dst, -1, 0, 0, 0, 0, 0, s_width, s_height);
11223 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage3D", "level is less than 0.");
11226 /* Check that INVALID_VALUE is generated by CopyTextureSubImage3D if
11227 xoffset<0, (xoffset+width)>w, yoffset<0, (yoffset+height)>h, zoffset<0,
11228 or (zoffset+1)>d, where w is the TEXTURE_WIDTH, h is the TEXTURE_HEIGHT,
11229 d is the TEXTURE_DEPTH and of the texture image being modified. Note
11230 that w, h, and d include twice the border width. */
11232 gl.copyTextureSubImage3D(m_to_3D_dst, 0, -1, 0, 0, 0, 0, s_width, s_height);
11233 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage3D", "xoffset<0.");
11235 gl.copyTextureSubImage3D(m_to_3D_dst, 0, 1, 0, 0, 0, 0, s_width, s_height);
11237 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage3D",
11238 "(xoffset+width)>w, where w is the TEXTURE_WIDTH of the texture image being modified.");
11240 gl.copyTextureSubImage3D(m_to_3D_dst, 0, 0, -1, 0, 0, 0, s_width, s_height);
11241 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage3D", "yoffset<0.");
11243 gl.copyTextureSubImage3D(m_to_3D_dst, 0, 0, 1, 0, 0, 0, s_width, s_height);
11245 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage3D",
11246 "(yoffset+height)>h, where h is the TEXTURE_HEIGHT of the texture image being modified.");
11248 gl.copyTextureSubImage3D(m_to_3D_dst, 0, 0, 0, -1, 0, 0, s_width, s_height);
11249 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage3D", "zoffset<0.");
11251 gl.copyTextureSubImage3D(m_to_3D_dst, 0, 0, 0, s_depth + 1, 0, 0, s_width, s_height);
11252 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage3D",
11253 "(zoffset+1)>d, where d is the TEXTURE_DEPTH of the texture image being modified.");
11256 /* Check that INVALID_OPERATION is generated by CopyTextureSubImage3D if
11257 the read buffer is NONE. */
11258 gl.readBuffer(GL_NONE);
11259 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11262 gl.copyTextureSubImage3D(m_to_3D_dst, 0, 0, 0, 0, 0, 0, s_width, s_height);
11264 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage3D", "the read buffer is NONE.");
11267 /* Bind multisample framebuffer. */
11268 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_ms);
11269 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11271 gl.readBuffer(GL_COLOR_ATTACHMENT0);
11272 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11274 /* Check that INVALID_OPERATION is generated by CopyTextureSubImage3D if
11275 the effective value of SAMPLE_BUFFERS for the read
11276 framebuffer is one. */
11278 gl.copyTextureSubImage3D(m_to_3D_dst, 0, 0, 0, 0, 0, 0, s_width, s_height);
11279 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage3D",
11280 "the effective value of SAMPLE_BUFFERS for the read framebuffer is one.");
11286 /** @brief Clean GL objects, test variables and GL errors.
11288 void CopyErrorsTest::Clean()
11290 /* Shortcut for GL functionality. */
11291 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
11296 gl.deleteFramebuffers(1, &m_fbo);
11303 gl.deleteFramebuffers(1, &m_fbo_ms);
11308 if (m_fbo_incomplete)
11310 gl.deleteFramebuffers(1, &m_fbo_incomplete);
11312 m_fbo_incomplete = 0;
11317 gl.deleteTextures(1, &m_to_src);
11324 gl.deleteTextures(1, &m_to_src_ms);
11331 gl.deleteTextures(1, &m_to_1D_dst);
11338 gl.deleteTextures(1, &m_to_2D_dst);
11345 gl.deleteTextures(1, &m_to_3D_dst);
11352 while (GL_NO_ERROR != gl.getError())
11356 /* Test's parameters. */
11357 const glw::GLuint CopyErrorsTest::s_width = 4;
11358 const glw::GLuint CopyErrorsTest::s_height = 4;
11359 const glw::GLuint CopyErrorsTest::s_depth = 4;
11360 const glw::GLuint CopyErrorsTest::s_internalformat = GL_RGBA8;
11362 /******************************** Parameter Setup Errors Test Implementation ********************************/
11364 /** @brief Parameter Setup Errors Test constructor.
11366 * @param [in] context OpenGL context.
11368 ParameterSetupErrorsTest::ParameterSetupErrorsTest(deqp::Context& context)
11369 : deqp::TestCase(context, "textures_parameter_setup_errors", "Texture Parameter Setup Errors Test")
11372 , m_to_rectangle(0)
11374 , m_pname_invalid(0)
11375 , m_depth_stencil_mode_invalid(0)
11377 /* Intentionally left blank. */
11380 /** @brief Iterate Parameter Setup Errors Test cases.
11382 * @return Iteration result.
11384 tcu::TestNode::IterateResult ParameterSetupErrorsTest::iterate()
11386 /* Get context setup. */
11387 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
11388 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
11390 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
11392 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
11397 /* Running tests. */
11399 bool is_error = false;
11409 is_ok &= TestIiv();
11410 is_ok &= TestIuiv();
11421 /* Result's setup. */
11424 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
11430 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
11434 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
11441 /** @brief Test's preparations.
11443 void ParameterSetupErrorsTest::Prepare()
11445 /* Shortcut for GL functionality. */
11446 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
11448 /* Auxiliary objects setup. */
11451 gl.createTextures(GL_TEXTURE_2D, 1, &m_to_2D);
11452 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
11455 gl.createTextures(GL_TEXTURE_2D_MULTISAMPLE, 1, &m_to_2D_ms);
11456 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
11459 gl.createTextures(GL_TEXTURE_RECTANGLE, 1, &m_to_rectangle);
11460 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
11462 /* Invalid texture object. */
11463 while (gl.isTexture(++m_to_invalid))
11465 GLU_EXPECT_NO_ERROR(gl.getError(), "glIsTexture has failed");
11467 /* Invalid parameter name. */
11468 glw::GLenum all_pnames[] = { GL_DEPTH_STENCIL_TEXTURE_MODE,
11469 GL_TEXTURE_BASE_LEVEL,
11470 GL_TEXTURE_COMPARE_FUNC,
11471 GL_TEXTURE_COMPARE_MODE,
11472 GL_TEXTURE_LOD_BIAS,
11473 GL_TEXTURE_MIN_FILTER,
11474 GL_TEXTURE_MAG_FILTER,
11475 GL_TEXTURE_MIN_LOD,
11476 GL_TEXTURE_MAX_LOD,
11477 GL_TEXTURE_MAX_LEVEL,
11478 GL_TEXTURE_SWIZZLE_R,
11479 GL_TEXTURE_SWIZZLE_G,
11480 GL_TEXTURE_SWIZZLE_B,
11481 GL_TEXTURE_SWIZZLE_A,
11485 GL_TEXTURE_BORDER_COLOR,
11486 GL_TEXTURE_SWIZZLE_RGBA };
11487 glw::GLuint all_pnames_count = sizeof(all_pnames) / sizeof(all_pnames[0]);
11489 bool is_valid = true;
11496 for (glw::GLuint i = 0; i < all_pnames_count; ++i)
11498 if (all_pnames[i] == m_pname_invalid)
11507 /* Invalid depth stencil mode name. */
11508 glw::GLenum all_depth_stencil_modes[] = { GL_DEPTH_COMPONENT, GL_STENCIL_INDEX };
11509 glw::GLuint all_depth_stencil_modes_count = sizeof(all_depth_stencil_modes) / sizeof(all_depth_stencil_modes[0]);
11516 ++m_depth_stencil_mode_invalid;
11518 for (glw::GLuint i = 0; i < all_depth_stencil_modes_count; ++i)
11520 if (all_depth_stencil_modes[i] == m_depth_stencil_mode_invalid)
11530 /** @brief Test (negative) of TextureParameterf
11532 * @return Test result.
11534 bool ParameterSetupErrorsTest::Testf()
11536 /* Shortcut for GL functionality. */
11537 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
11542 /* Check that INVALID_ENUM is generated by TextureParameter* if pname is
11543 not one of the accepted defined values. */
11545 gl.textureParameterf(m_to_2D, m_pname_invalid, 1.f);
11547 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterf",
11548 "pname is not one of the accepted defined values.");
11551 /* Check that INVALID_ENUM is generated by TextureParameter* if params
11552 should have a defined constant value (based on the value of pname) and
11555 gl.textureParameterf(m_to_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, (glw::GLfloat)m_depth_stencil_mode_invalid);
11558 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterf",
11559 "params should have a defined constant value (based on the value of pname) and does not.");
11561 /* Check that INVALID_ENUM is generated if TextureParameter{if} is called
11562 for a non-scalar parameter (pname TEXTURE_BORDER_COLOR or
11563 TEXTURE_SWIZZLE_RGBA). */
11565 gl.textureParameterf(m_to_2D, GL_TEXTURE_BORDER_COLOR, 1.f);
11568 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterf",
11569 "called for a non-scalar parameter (pname TEXTURE_BORDER_COLOR or TEXTURE_SWIZZLE_RGBA).");
11572 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11573 effective target is either TEXTURE_2D_MULTISAMPLE or
11574 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states. */
11576 gl.textureParameterf(m_to_2D_ms, GL_TEXTURE_LOD_BIAS, 1.f);
11578 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterf",
11579 "the effective target is either TEXTURE_2D_MULTISAMPLE or "
11580 "TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states.");
11583 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11584 effective target is TEXTURE_RECTANGLE and either of pnames
11585 TEXTURE_WRAP_S or TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE,
11586 MIRRORED_REPEAT or REPEAT. */
11588 gl.textureParameterf(m_to_rectangle, GL_TEXTURE_WRAP_S, GL_MIRROR_CLAMP_TO_EDGE);
11590 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterf",
11591 "the effective target is TEXTURE_RECTANGLE and either of pnames TEXTURE_WRAP_S or "
11592 "TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE, MIRRORED_REPEAT or REPEAT.");
11595 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11596 effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is
11597 set to a value other than NEAREST or LINEAR (no mipmap filtering is
11600 gl.textureParameterf(m_to_rectangle, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
11602 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterf",
11603 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is set to a "
11604 "value other than NEAREST or LINEAR (no mipmap filtering is permitted).");
11607 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
11608 effective target is either TEXTURE_2D_MULTISAMPLE or
11609 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname TEXTURE_BASE_LEVEL is set to a
11610 value other than zero. */
11612 gl.textureParameterf(m_to_2D_ms, GL_TEXTURE_BASE_LEVEL, 1.f);
11615 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterf",
11616 "the effective target is either TEXTURE_2D_MULTISAMPLE or TEXTURE_2D_MULTISAMPLE_ARRAY, "
11617 "and pname TEXTURE_BASE_LEVEL is set to a value other than zero.");
11620 /* Check that INVALID_OPERATION is generated by TextureParameter* if
11621 texture is not the name of an existing texture object. */
11623 gl.textureParameterf(m_to_invalid, GL_TEXTURE_LOD_BIAS, 1.f);
11625 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterf",
11626 "texture is not the name of an existing texture object.");
11629 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
11630 effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is
11631 set to any value other than zero. */
11633 gl.textureParameterf(m_to_rectangle, GL_TEXTURE_BASE_LEVEL, 1.f);
11635 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterf",
11636 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is set to "
11637 "any value other than zero. ");
11640 /* Check that INVALID_VALUE is generated by TextureParameter* if pname is
11641 TEXTURE_BASE_LEVEL or TEXTURE_MAX_LEVEL, and param or params is
11644 gl.textureParameterf(m_to_2D, GL_TEXTURE_BASE_LEVEL, -1.f);
11646 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureParameterf",
11647 "pname is TEXTURE_BASE_LEVEL and param is negative.");
11649 gl.textureParameterf(m_to_2D, GL_TEXTURE_MAX_LEVEL, -1.f);
11651 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureParameterf",
11652 "pname is TEXTURE_MAX_LEVEL and param is negative.");
11658 /** @brief Test (negative) of TextureParameteri
11660 * @return Test result.
11662 bool ParameterSetupErrorsTest::Testi()
11664 /* Shortcut for GL functionality. */
11665 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
11670 /* Check that INVALID_ENUM is generated by TextureParameter* if pname is
11671 not one of the accepted defined values. */
11673 gl.textureParameteri(m_to_2D, m_pname_invalid, 1);
11675 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteri",
11676 "pname is not one of the accepted defined values.");
11679 /* Check that INVALID_ENUM is generated by TextureParameter* if params
11680 should have a defined constant value (based on the value of pname) and
11683 gl.textureParameteri(m_to_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, m_depth_stencil_mode_invalid);
11686 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteri",
11687 "params should have a defined constant value (based on the value of pname) and does not.");
11689 /* Check that INVALID_ENUM is generated if TextureParameter{if} is called
11690 for a non-scalar parameter (pname TEXTURE_BORDER_COLOR or
11691 TEXTURE_SWIZZLE_RGBA). */
11693 gl.textureParameteri(m_to_2D, GL_TEXTURE_BORDER_COLOR, 1);
11696 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteri",
11697 "called for a non-scalar parameter (pname TEXTURE_BORDER_COLOR or TEXTURE_SWIZZLE_RGBA).");
11700 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11701 effective target is either TEXTURE_2D_MULTISAMPLE or
11702 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states. */
11704 gl.textureParameteri(m_to_2D_ms, GL_TEXTURE_LOD_BIAS, 1);
11706 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteri",
11707 "the effective target is either TEXTURE_2D_MULTISAMPLE or "
11708 "TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states.");
11711 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11712 effective target is TEXTURE_RECTANGLE and either of pnames
11713 TEXTURE_WRAP_S or TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE,
11714 MIRRORED_REPEAT or REPEAT. */
11716 gl.textureParameteri(m_to_rectangle, GL_TEXTURE_WRAP_S, GL_MIRROR_CLAMP_TO_EDGE);
11718 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteri",
11719 "the effective target is TEXTURE_RECTANGLE and either of pnames TEXTURE_WRAP_S or "
11720 "TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE, MIRRORED_REPEAT or REPEAT.");
11723 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11724 effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is
11725 set to a value other than NEAREST or LINEAR (no mipmap filtering is
11728 gl.textureParameteri(m_to_rectangle, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
11730 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteri",
11731 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is set to a "
11732 "value other than NEAREST or LINEAR (no mipmap filtering is permitted).");
11735 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
11736 effective target is either TEXTURE_2D_MULTISAMPLE or
11737 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname TEXTURE_BASE_LEVEL is set to a
11738 value other than zero. */
11740 gl.textureParameteri(m_to_2D_ms, GL_TEXTURE_BASE_LEVEL, 1);
11743 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameteri",
11744 "the effective target is either TEXTURE_2D_MULTISAMPLE or TEXTURE_2D_MULTISAMPLE_ARRAY, "
11745 "and pname TEXTURE_BASE_LEVEL is set to a value other than zero.");
11748 /* Check that INVALID_OPERATION is generated by TextureParameter* if
11749 texture is not the name of an existing texture object. */
11751 gl.textureParameteri(m_to_invalid, GL_TEXTURE_LOD_BIAS, 1);
11753 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameteri",
11754 "texture is not the name of an existing texture object.");
11757 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
11758 effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is
11759 set to any value other than zero. */
11761 gl.textureParameteri(m_to_rectangle, GL_TEXTURE_BASE_LEVEL, 1);
11763 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameteri",
11764 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is set to "
11765 "any value other than zero. ");
11768 /* Check that INVALID_VALUE is generated by TextureParameter* if pname is
11769 TEXTURE_BASE_LEVEL or TEXTURE_MAX_LEVEL, and param or params is
11772 gl.textureParameteri(m_to_2D, GL_TEXTURE_BASE_LEVEL, -1);
11774 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureParameteri",
11775 "pname is TEXTURE_BASE_LEVEL and param is negative.");
11777 gl.textureParameteri(m_to_2D, GL_TEXTURE_MAX_LEVEL, -1);
11779 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureParameteri",
11780 "pname is TEXTURE_MAX_LEVEL and param is negative.");
11786 /** @brief Test (negative) of TextureParameterfv
11788 * @return Test result.
11790 bool ParameterSetupErrorsTest::Testfv()
11792 /* Shortcut for GL functionality. */
11793 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
11798 glw::GLfloat one = 1.f;
11799 glw::GLfloat minus_one = -1.f;
11800 glw::GLfloat depth_stencil_mode_invalid = (glw::GLfloat)m_depth_stencil_mode_invalid;
11801 glw::GLfloat wrap_invalid = (glw::GLfloat)GL_MIRROR_CLAMP_TO_EDGE;
11802 glw::GLfloat min_filter_invalid = (glw::GLfloat)GL_NEAREST_MIPMAP_NEAREST;
11804 /* Check that INVALID_ENUM is generated by TextureParameter* if pname is
11805 not one of the accepted defined values. */
11807 gl.textureParameterfv(m_to_2D, m_pname_invalid, &one);
11809 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterfv",
11810 "pname is not one of the accepted defined values.");
11813 /* Check that INVALID_ENUM is generated by TextureParameter* if params
11814 should have a defined constant value (based on the value of pname) and
11817 gl.textureParameterfv(m_to_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, &depth_stencil_mode_invalid);
11820 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterfv",
11821 "params should have a defined constant value (based on the value of pname) and does not.");
11824 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11825 effective target is either TEXTURE_2D_MULTISAMPLE or
11826 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states. */
11828 gl.textureParameterfv(m_to_2D_ms, GL_TEXTURE_LOD_BIAS, &one);
11830 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterfv",
11831 "the effective target is either TEXTURE_2D_MULTISAMPLE or "
11832 "TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states.");
11835 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11836 effective target is TEXTURE_RECTANGLE and either of pnames
11837 TEXTURE_WRAP_S or TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE,
11838 MIRRORED_REPEAT or REPEAT. */
11840 gl.textureParameterfv(m_to_rectangle, GL_TEXTURE_WRAP_S, &wrap_invalid);
11842 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterfv",
11843 "the effective target is TEXTURE_RECTANGLE and either of pnames TEXTURE_WRAP_S or "
11844 "TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE, MIRRORED_REPEAT or REPEAT.");
11847 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11848 effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is
11849 set to a value other than NEAREST or LINEAR (no mipmap filtering is
11852 gl.textureParameterfv(m_to_rectangle, GL_TEXTURE_MIN_FILTER, &min_filter_invalid);
11854 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterfv",
11855 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is set to a "
11856 "value other than NEAREST or LINEAR (no mipmap filtering is permitted).");
11859 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
11860 effective target is either TEXTURE_2D_MULTISAMPLE or
11861 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname TEXTURE_BASE_LEVEL is set to a
11862 value other than zero. */
11864 gl.textureParameterfv(m_to_2D_ms, GL_TEXTURE_BASE_LEVEL, &one);
11867 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterfv",
11868 "the effective target is either TEXTURE_2D_MULTISAMPLE or TEXTURE_2D_MULTISAMPLE_ARRAY, "
11869 "and pname TEXTURE_BASE_LEVEL is set to a value other than zero.");
11872 /* Check that INVALID_OPERATION is generated by TextureParameter* if
11873 texture is not the name of an existing texture object. */
11875 gl.textureParameterfv(m_to_invalid, GL_TEXTURE_LOD_BIAS, &one);
11877 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterfv",
11878 "texture is not the name of an existing texture object.");
11881 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
11882 effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is
11883 set to any value other than zero. */
11885 gl.textureParameterfv(m_to_rectangle, GL_TEXTURE_BASE_LEVEL, &one);
11887 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterfv",
11888 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is set to "
11889 "any value other than zero. ");
11892 /* Check that INVALID_VALUE is generated by TextureParameter* if pname is
11893 TEXTURE_BASE_LEVEL or TEXTURE_MAX_LEVEL, and param or params is
11896 gl.textureParameterfv(m_to_2D, GL_TEXTURE_BASE_LEVEL, &minus_one);
11898 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureParameterfv",
11899 "pname is TEXTURE_BASE_LEVEL and param is negative.");
11901 gl.textureParameterfv(m_to_2D, GL_TEXTURE_MAX_LEVEL, &minus_one);
11903 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureParameterfv",
11904 "pname is TEXTURE_MAX_LEVEL and param is negative.");
11910 /** @brief Test (negative) of TextureParameteriv
11912 * @return Test result.
11914 bool ParameterSetupErrorsTest::Testiv()
11916 /* Shortcut for GL functionality. */
11917 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
11922 glw::GLint one = 1;
11923 glw::GLint minus_one = -1;
11924 glw::GLint depth_stencil_mode_invalid = (glw::GLint)m_depth_stencil_mode_invalid;
11925 glw::GLint wrap_invalid = (glw::GLint)GL_MIRROR_CLAMP_TO_EDGE;
11926 glw::GLint min_filter_invalid = (glw::GLint)GL_NEAREST_MIPMAP_NEAREST;
11928 /* Check that INVALID_ENUM is generated by TextureParameter* if pname is
11929 not one of the accepted defined values. */
11931 gl.textureParameteriv(m_to_2D, m_pname_invalid, &one);
11933 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteriv",
11934 "pname is not one of the accepted defined values.");
11937 /* Check that INVALID_ENUM is generated by TextureParameter* if params
11938 should have a defined constant value (based on the value of pname) and
11941 gl.textureParameteriv(m_to_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, &depth_stencil_mode_invalid);
11944 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteriv",
11945 "params should have a defined constant value (based on the value of pname) and does not.");
11948 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11949 effective target is either TEXTURE_2D_MULTISAMPLE or
11950 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states. */
11952 gl.textureParameteriv(m_to_2D_ms, GL_TEXTURE_LOD_BIAS, &one);
11954 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteriv",
11955 "the effective target is either TEXTURE_2D_MULTISAMPLE or "
11956 "TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states.");
11959 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11960 effective target is TEXTURE_RECTANGLE and either of pnames
11961 TEXTURE_WRAP_S or TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE,
11962 MIRRORED_REPEAT or REPEAT. */
11964 gl.textureParameteriv(m_to_rectangle, GL_TEXTURE_WRAP_S, &wrap_invalid);
11966 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteriv",
11967 "the effective target is TEXTURE_RECTANGLE and either of pnames TEXTURE_WRAP_S or "
11968 "TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE, MIRRORED_REPEAT or REPEAT.");
11971 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11972 effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is
11973 set to a value other than NEAREST or LINEAR (no mipmap filtering is
11976 gl.textureParameteriv(m_to_rectangle, GL_TEXTURE_MIN_FILTER, &min_filter_invalid);
11978 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteriv",
11979 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is set to a "
11980 "value other than NEAREST or LINEAR (no mipmap filtering is permitted).");
11983 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
11984 effective target is either TEXTURE_2D_MULTISAMPLE or
11985 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname TEXTURE_BASE_LEVEL is set to a
11986 value other than zero. */
11988 gl.textureParameteriv(m_to_2D_ms, GL_TEXTURE_BASE_LEVEL, &one);
11991 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameteriv",
11992 "the effective target is either TEXTURE_2D_MULTISAMPLE or TEXTURE_2D_MULTISAMPLE_ARRAY, "
11993 "and pname TEXTURE_BASE_LEVEL is set to a value other than zero.");
11996 /* Check that INVALID_OPERATION is generated by TextureParameter* if
11997 texture is not the name of an existing texture object. */
11999 gl.textureParameteriv(m_to_invalid, GL_TEXTURE_LOD_BIAS, &one);
12001 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameteriv",
12002 "texture is not the name of an existing texture object.");
12005 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
12006 effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is
12007 set to any value other than zero. */
12009 gl.textureParameteriv(m_to_rectangle, GL_TEXTURE_BASE_LEVEL, &one);
12011 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameteriv",
12012 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is set to "
12013 "any value other than zero. ");
12016 /* Check that INVALID_VALUE is generated by TextureParameter* if pname is
12017 TEXTURE_BASE_LEVEL or TEXTURE_MAX_LEVEL, and param or params is
12020 gl.textureParameteriv(m_to_2D, GL_TEXTURE_BASE_LEVEL, &minus_one);
12022 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureParameteriv",
12023 "pname is TEXTURE_BASE_LEVEL and param is negative.");
12025 gl.textureParameteriv(m_to_2D, GL_TEXTURE_MAX_LEVEL, &minus_one);
12027 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureParameteriv",
12028 "pname is TEXTURE_MAX_LEVEL and param is negative.");
12034 /** @brief Test (negative) of TextureParameterIiv
12036 * @return Test result.
12038 bool ParameterSetupErrorsTest::TestIiv()
12040 /* Shortcut for GL functionality. */
12041 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
12046 glw::GLint one = 1;
12047 glw::GLint minus_one = -1;
12048 glw::GLint depth_stencil_mode_invalid = (glw::GLint)m_depth_stencil_mode_invalid;
12049 glw::GLint wrap_invalid = (glw::GLint)GL_MIRROR_CLAMP_TO_EDGE;
12050 glw::GLint min_filter_invalid = (glw::GLint)GL_NEAREST_MIPMAP_NEAREST;
12052 /* Check that INVALID_ENUM is generated by TextureParameter* if pname is
12053 not one of the accepted defined values. */
12055 gl.textureParameterIiv(m_to_2D, m_pname_invalid, &one);
12057 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterIiv",
12058 "pname is not one of the accepted defined values.");
12061 /* Check that INVALID_ENUM is generated by TextureParameter* if params
12062 should have a defined constant value (based on the value of pname) and
12065 gl.textureParameterIiv(m_to_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, &depth_stencil_mode_invalid);
12068 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterIiv",
12069 "params should have a defined constant value (based on the value of pname) and does not.");
12072 /* Check that INVALID_ENUM is generated by TextureParameter* if the
12073 effective target is either TEXTURE_2D_MULTISAMPLE or
12074 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states. */
12076 gl.textureParameterIiv(m_to_2D_ms, GL_TEXTURE_LOD_BIAS, &one);
12078 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterIiv",
12079 "the effective target is either TEXTURE_2D_MULTISAMPLE or "
12080 "TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states.");
12083 /* Check that INVALID_ENUM is generated by TextureParameter* if the
12084 effective target is TEXTURE_RECTANGLE and either of pnames
12085 TEXTURE_WRAP_S or TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE,
12086 MIRRORED_REPEAT or REPEAT. */
12088 gl.textureParameterIiv(m_to_rectangle, GL_TEXTURE_WRAP_S, &wrap_invalid);
12090 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterIiv",
12091 "the effective target is TEXTURE_RECTANGLE and either of pnames TEXTURE_WRAP_S or "
12092 "TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE, MIRRORED_REPEAT or REPEAT.");
12095 /* Check that INVALID_ENUM is generated by TextureParameter* if the
12096 effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is
12097 set to a value other than NEAREST or LINEAR (no mipmap filtering is
12100 gl.textureParameterIiv(m_to_rectangle, GL_TEXTURE_MIN_FILTER, &min_filter_invalid);
12102 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterIiv",
12103 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is set to a "
12104 "value other than NEAREST or LINEAR (no mipmap filtering is permitted).");
12107 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
12108 effective target is either TEXTURE_2D_MULTISAMPLE or
12109 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname TEXTURE_BASE_LEVEL is set to a
12110 value other than zero. */
12112 gl.textureParameterIiv(m_to_2D_ms, GL_TEXTURE_BASE_LEVEL, &one);
12115 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterIiv",
12116 "the effective target is either TEXTURE_2D_MULTISAMPLE or TEXTURE_2D_MULTISAMPLE_ARRAY, "
12117 "and pname TEXTURE_BASE_LEVEL is set to a value other than zero.");
12120 /* Check that INVALID_OPERATION is generated by TextureParameter* if
12121 texture is not the name of an existing texture object. */
12123 gl.textureParameterIiv(m_to_invalid, GL_TEXTURE_LOD_BIAS, &one);
12125 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterIiv",
12126 "texture is not the name of an existing texture object.");
12129 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
12130 effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is
12131 set to any value other than zero. */
12133 gl.textureParameterIiv(m_to_rectangle, GL_TEXTURE_BASE_LEVEL, &one);
12135 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterIiv",
12136 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is set to "
12137 "any value other than zero. ");
12140 /* Check that INVALID_VALUE is generated by TextureParameter* if pname is
12141 TEXTURE_BASE_LEVEL or TEXTURE_MAX_LEVEL, and param or params is
12144 gl.textureParameterIiv(m_to_2D, GL_TEXTURE_BASE_LEVEL, &minus_one);
12146 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureParameterIiv",
12147 "pname is TEXTURE_BASE_LEVEL and param is negative.");
12149 gl.textureParameterIiv(m_to_2D, GL_TEXTURE_MAX_LEVEL, &minus_one);
12151 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureParameterIiv",
12152 "pname is TEXTURE_MAX_LEVEL and param is negative.");
12158 /** @brief Test (negative) of TextureParameterIuiv
12160 * @return Test result.
12162 bool ParameterSetupErrorsTest::TestIuiv()
12164 /* Shortcut for GL functionality. */
12165 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
12170 glw::GLuint one = 1;
12171 glw::GLuint depth_stencil_mode_invalid = (glw::GLint)m_depth_stencil_mode_invalid;
12172 glw::GLuint wrap_invalid = (glw::GLint)GL_MIRROR_CLAMP_TO_EDGE;
12173 glw::GLuint min_filter_invalid = (glw::GLint)GL_NEAREST_MIPMAP_NEAREST;
12175 /* Check that INVALID_ENUM is generated by TextureParameter* if pname is
12176 not one of the accepted defined values. */
12178 gl.textureParameterIuiv(m_to_2D, m_pname_invalid, &one);
12180 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterIuiv",
12181 "pname is not one of the accepted defined values.");
12184 /* Check that INVALID_ENUM is generated by TextureParameter* if params
12185 should have a defined constant value (based on the value of pname) and
12188 gl.textureParameterIuiv(m_to_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, &depth_stencil_mode_invalid);
12191 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterIuiv",
12192 "params should have a defined constant value (based on the value of pname) and does not.");
12195 /* Check that INVALID_ENUM is generated by TextureParameter* if the
12196 effective target is either TEXTURE_2D_MULTISAMPLE or
12197 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states. */
12199 gl.textureParameterIuiv(m_to_2D_ms, GL_TEXTURE_LOD_BIAS, &one);
12201 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterIuiv",
12202 "the effective target is either TEXTURE_2D_MULTISAMPLE or "
12203 "TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states.");
12206 /* Check that INVALID_ENUM is generated by TextureParameter* if the
12207 effective target is TEXTURE_RECTANGLE and either of pnames
12208 TEXTURE_WRAP_S or TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE,
12209 MIRRORED_REPEAT or REPEAT. */
12211 gl.textureParameterIuiv(m_to_rectangle, GL_TEXTURE_WRAP_S, &wrap_invalid);
12213 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterIuiv",
12214 "the effective target is TEXTURE_RECTANGLE and either of pnames TEXTURE_WRAP_S or "
12215 "TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE, MIRRORED_REPEAT or REPEAT.");
12218 /* Check that INVALID_ENUM is generated by TextureParameter* if the
12219 effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is
12220 set to a value other than NEAREST or LINEAR (no mipmap filtering is
12223 gl.textureParameterIuiv(m_to_rectangle, GL_TEXTURE_MIN_FILTER, &min_filter_invalid);
12225 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterIuiv",
12226 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is set to a "
12227 "value other than NEAREST or LINEAR (no mipmap filtering is permitted).");
12230 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
12231 effective target is either TEXTURE_2D_MULTISAMPLE or
12232 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname TEXTURE_BASE_LEVEL is set to a
12233 value other than zero. */
12235 gl.textureParameterIuiv(m_to_2D_ms, GL_TEXTURE_BASE_LEVEL, &one);
12238 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterIuiv",
12239 "the effective target is either TEXTURE_2D_MULTISAMPLE or TEXTURE_2D_MULTISAMPLE_ARRAY, "
12240 "and pname TEXTURE_BASE_LEVEL is set to a value other than zero.");
12243 /* Check that INVALID_OPERATION is generated by TextureParameter* if
12244 texture is not the name of an existing texture object. */
12246 gl.textureParameterIuiv(m_to_invalid, GL_TEXTURE_LOD_BIAS, &one);
12248 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterIuiv",
12249 "texture is not the name of an existing texture object.");
12252 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
12253 effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is
12254 set to any value other than zero. */
12256 gl.textureParameterIuiv(m_to_rectangle, GL_TEXTURE_BASE_LEVEL, &one);
12258 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterIuiv",
12259 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is set to "
12260 "any value other than zero. ");
12266 /** @brief Clean GL objects, test variables and GL errors.
12268 void ParameterSetupErrorsTest::Clean()
12270 /* Shortcut for GL functionality. */
12271 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
12276 gl.deleteTextures(1, &m_to_2D);
12283 gl.deleteTextures(1, &m_to_2D_ms);
12288 if (m_to_rectangle)
12290 gl.deleteTextures(1, &m_to_rectangle);
12292 m_to_rectangle = 0;
12297 gl.deleteTextures(1, &m_to_invalid);
12303 m_pname_invalid = 0;
12305 while (GL_NO_ERROR != gl.getError())
12309 /******************************** Generate Mipmap Errors Test Implementation ********************************/
12311 /** @brief Generate Mipmap Errors Test constructor.
12313 * @param [in] context OpenGL context.
12315 GenerateMipmapErrorsTest::GenerateMipmapErrorsTest(deqp::Context& context)
12316 : deqp::TestCase(context, "textures_generate_mipmap_errors", "Texture Generate Mipmap Errors Test")
12318 /* Intentionally left blank. */
12321 /** @brief Iterate Generate Mipmap Errors Test cases.
12323 * @return Iteration result.
12325 tcu::TestNode::IterateResult GenerateMipmapErrorsTest::iterate()
12327 /* Shortcut for GL functionality. */
12328 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
12330 /* Get context setup. */
12331 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
12332 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
12334 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
12336 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
12341 /* Running tests. */
12343 bool is_error = false;
12346 glw::GLuint texture_invalid = 0;
12347 glw::GLuint texture_cube = 0;
12351 /* Preparations. */
12353 /* incomplete cube map */
12354 gl.genTextures(1, &texture_cube);
12355 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
12357 gl.bindTexture(GL_TEXTURE_CUBE_MAP, texture_cube);
12358 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
12360 gl.texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, s_reference_internalformat, s_reference_width,
12361 s_reference_height, 0, s_reference_format, s_reference_type, s_reference_data);
12362 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
12364 /* invalid texture */
12365 while (gl.isTexture(++texture_invalid))
12368 /* Check that INVALID_OPERATION is generated by GenerateTextureMipmap if
12369 texture is not the name of an existing texture object. */
12370 gl.generateTextureMipmap(texture_invalid);
12371 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGenerateTextureMipmap",
12372 "texture is not the name of an existing texture object.");
12374 /* Check that INVALID_OPERATION is generated by GenerateTextureMipmap if
12375 target is TEXTURE_CUBE_MAP or TEXTURE_CUBE_MAP_ARRAY, and the specified
12376 texture object is not cube complete or cube array complete,
12378 gl.generateTextureMipmap(texture_cube);
12379 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGenerateTextureMipmap",
12380 "target is TEXTURE_CUBE_MAP or TEXTURE_CUBE_MAP_ARRAY, and the specified texture "
12381 "object is not cube complete or cube array complete, respectively.");
12392 gl.deleteTextures(1, &texture_cube);
12395 while (GL_NO_ERROR != gl.getError())
12398 /* Result's setup. */
12401 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
12407 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
12411 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
12418 /** Reference data. */
12419 const glw::GLubyte GenerateMipmapErrorsTest::s_reference_data[] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
12420 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF };
12422 /** Reference data parameters. */
12423 const glw::GLuint GenerateMipmapErrorsTest::s_reference_width = 4;
12424 const glw::GLuint GenerateMipmapErrorsTest::s_reference_height = 4;
12425 const glw::GLenum GenerateMipmapErrorsTest::s_reference_internalformat = GL_R8;
12426 const glw::GLenum GenerateMipmapErrorsTest::s_reference_format = GL_RED;
12427 const glw::GLenum GenerateMipmapErrorsTest::s_reference_type = GL_UNSIGNED_BYTE;
12429 /******************************** Bind Unit Errors Test Implementation ********************************/
12431 /** @brief Bind Unit Errors Test constructor.
12433 * @param [in] context OpenGL context.
12435 BindUnitErrorsTest::BindUnitErrorsTest(deqp::Context& context)
12436 : deqp::TestCase(context, "textures_bind_unit_errors", "Texture Bind Unit Errors Test")
12438 /* Intentionally left blank. */
12441 /** @brief IterateBind Unit Errors Test cases.
12443 * @return Iteration result.
12445 tcu::TestNode::IterateResult BindUnitErrorsTest::iterate()
12447 /* Shortcut for GL functionality. */
12448 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
12450 /* Get context setup. */
12451 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
12452 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
12454 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
12456 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
12461 /* Running tests. */
12463 bool is_error = false;
12466 glw::GLuint texture_invalid = 0;
12470 /* Prepare invalid texture */
12471 while (gl.isTexture(++texture_invalid))
12474 /* incomplete cube map */
12476 /* Check that INVALID_OPERATION error is generated if texture is not zero
12477 or the name of an existing texture object. */
12478 gl.bindTextureUnit(0, texture_invalid);
12479 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glBindTextureUnit",
12480 "texture is not zero or the name of an existing texture object.");
12489 while (GL_NO_ERROR != gl.getError())
12492 /* Result's setup. */
12495 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
12501 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
12505 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
12512 /******************************** Image Query Errors Test Implementation ********************************/
12514 /** @brief Image Query Errors Test constructor.
12516 * @param [in] context OpenGL context.
12518 ImageQueryErrorsTest::ImageQueryErrorsTest(deqp::Context& context)
12519 : deqp::TestCase(context, "textures_image_query_errors", "Texture Image Query Errors Test")
12521 /* Intentionally left blank. */
12524 /** Reference data. */
12525 const glw::GLuint ImageQueryErrorsTest::s_reference_data[] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
12526 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF };
12528 /** Reference data parameters. */
12529 const glw::GLuint ImageQueryErrorsTest::s_reference_width = 4;
12530 const glw::GLuint ImageQueryErrorsTest::s_reference_height = 4;
12531 const glw::GLuint ImageQueryErrorsTest::s_reference_size = sizeof(s_reference_data);
12532 const glw::GLenum ImageQueryErrorsTest::s_reference_internalformat = GL_R8;
12533 const glw::GLenum ImageQueryErrorsTest::s_reference_internalformat_int = GL_R8I;
12534 const glw::GLenum ImageQueryErrorsTest::s_reference_internalformat_compressed = GL_COMPRESSED_RED_RGTC1;
12535 const glw::GLenum ImageQueryErrorsTest::s_reference_format = GL_RED;
12536 const glw::GLenum ImageQueryErrorsTest::s_reference_type = GL_UNSIGNED_INT;
12538 /** @brief Iterate Image Query Errors Test cases.
12540 * @return Iteration result.
12542 tcu::TestNode::IterateResult ImageQueryErrorsTest::iterate()
12544 /* Shortcut for GL functionality. */
12545 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
12547 /* Get context setup. */
12548 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
12549 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
12551 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
12553 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
12558 /* Running tests. */
12560 bool is_error = false;
12563 glw::GLuint buffer = 0;
12564 glw::GLuint texture_invalid = 0;
12565 glw::GLuint texture_2D = 0;
12566 glw::GLuint texture_2D_int = 0;
12567 glw::GLuint texture_2D_ms = 0;
12568 glw::GLuint texture_2D_stencil = 0;
12569 glw::GLuint texture_2D_compressed = 0;
12570 glw::GLuint texture_cube = 0;
12571 glw::GLuint texture_rectangle = 0;
12572 glw::GLint max_level = 0;
12573 char store[s_reference_size * 6 /* for cubemap */] = {};
12577 /* Preparations. */
12580 gl.createBuffers(1, &buffer);
12582 gl.namedBufferData(buffer, s_reference_size + 1, NULL, GL_STATIC_COPY);
12583 GLU_EXPECT_NO_ERROR(gl.getError(), "glNamedBufferData has failed");
12586 gl.genTextures(1, &texture_2D);
12587 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
12589 gl.bindTexture(GL_TEXTURE_2D, texture_2D);
12590 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
12592 gl.texImage2D(GL_TEXTURE_2D, 0, s_reference_internalformat, s_reference_width, s_reference_height, 0,
12593 s_reference_format, s_reference_type, s_reference_data);
12594 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
12597 gl.genTextures(1, &texture_2D);
12598 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
12600 gl.bindTexture(GL_TEXTURE_2D, texture_2D);
12601 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
12603 gl.texImage2D(GL_TEXTURE_2D, 0, s_reference_internalformat, s_reference_width, s_reference_height, 0,
12604 s_reference_format, s_reference_type, s_reference_data);
12605 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
12607 /* incomplete cube map */
12608 gl.genTextures(1, &texture_cube);
12609 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
12611 gl.bindTexture(GL_TEXTURE_CUBE_MAP, texture_cube);
12612 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
12614 gl.texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, s_reference_internalformat, s_reference_width,
12615 s_reference_height, 0, s_reference_format, s_reference_type, s_reference_data);
12616 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
12618 /* 2D multisample */
12619 gl.createTextures(GL_TEXTURE_2D_MULTISAMPLE, 1, &texture_2D_ms);
12620 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
12622 gl.textureStorage2DMultisample(texture_2D_ms, 1, s_reference_internalformat, s_reference_width,
12623 s_reference_height, false);
12624 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage2DMultisample has failed");
12627 gl.createTextures(GL_TEXTURE_2D, 1, &texture_2D_stencil);
12628 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
12630 gl.textureStorage2D(texture_2D_stencil, 1, GL_STENCIL_INDEX8, s_reference_width, s_reference_height);
12631 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage2DMultisample has failed");
12633 /* 2D compressed texture */
12634 gl.genTextures(1, &texture_2D_compressed);
12635 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
12637 gl.bindTexture(GL_TEXTURE_2D, texture_2D_compressed);
12638 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
12640 gl.texImage2D(GL_TEXTURE_2D, 0, s_reference_internalformat_compressed, s_reference_width, s_reference_height, 0,
12641 s_reference_format, s_reference_type, s_reference_data);
12642 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
12644 gl.getIntegerv(GL_MAX_TEXTURE_SIZE, &max_level); /* assuming that x > log(x) */
12645 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
12647 /* Rectangle texture */
12648 gl.genTextures(1, &texture_rectangle);
12649 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
12651 gl.bindTexture(GL_TEXTURE_RECTANGLE, texture_rectangle);
12652 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
12654 gl.texImage2D(GL_TEXTURE_RECTANGLE, 0, s_reference_internalformat, s_reference_width, s_reference_height, 0,
12655 s_reference_format, s_reference_type, s_reference_data);
12656 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
12658 /* invalid texture */
12659 while (gl.isTexture(++texture_invalid))
12664 /* Check that INVALID_OPERATION is generated by GetTextureImage functions if
12665 resulting texture target is not an accepted value TEXTURE_1D,
12666 TEXTURE_2D, TEXTURE_3D, TEXTURE_1D_ARRAY, TEXTURE_2D_ARRAY,
12667 TEXTURE_CUBE_MAP_ARRAY, TEXTURE_RECTANGLE, and TEXTURE_CUBE_MAP. */
12668 gl.getTextureImage(texture_2D_ms, 0, s_reference_format, s_reference_type, s_reference_size, store);
12669 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12670 "resulting texture target is not an accepted value TEXTURE_1D, TEXTURE_2D, "
12671 "TEXTURE_3D, TEXTURE_1D_ARRAY, TEXTURE_2D_ARRAY, TEXTURE_CUBE_MAP_ARRAY, "
12672 "TEXTURE_RECTANGLE, and TEXTURE_CUBE_MAP.");
12674 /* Check that INVALID_OPERATION is generated by GetTextureImage
12675 if texture is not the name of an existing texture object. */
12676 gl.getTextureImage(texture_invalid, 0, s_reference_format, s_reference_type, s_reference_size, store);
12677 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12678 "texture is not the name of an existing texture object.");
12680 /* Check that INVALID_OPERATION error is generated by GetTextureImage if
12681 the effective target is TEXTURE_CUBE_MAP or TEXTURE_CUBE_MAP_ARRAY, and
12682 the texture object is not cube complete or cube array complete,
12684 gl.getTextureImage(texture_cube, 0, s_reference_format, s_reference_type, s_reference_size * 6, store);
12685 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12686 "the effective target is TEXTURE_CUBE_MAP and the texture object is not cube "
12687 "complete or cube array complete, respectively.");
12689 /* Check that GL_INVALID_VALUE is generated if level is less than 0 or
12690 larger than the maximum allowable level. */
12691 gl.getTextureImage(texture_2D, -1, s_reference_format, s_reference_type, s_reference_size, store);
12692 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glGetTextureImage", "level is less than 0.");
12694 gl.getTextureImage(texture_2D, max_level, s_reference_format, s_reference_type, s_reference_size, store);
12695 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glGetTextureImage",
12696 "level is larger than the maximum allowable level.");
12698 /* Check that INVALID_VALUE error is generated if level is non-zero and the
12699 effective target is TEXTURE_RECTANGLE. */
12700 gl.getTextureImage(texture_rectangle, 1, s_reference_format, s_reference_type, s_reference_size, store);
12701 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glGetTextureImage",
12702 "level is non-zero and the effective target is TEXTURE_RECTANGLE.");
12704 /* Check that INVALID_OPERATION error is generated if any of the following
12705 mismatches between format and the internal format of the texture image
12707 - format is a color format (one of the formats in table 8.3 whose
12708 target is the color buffer) and the base internal format of the
12709 texture image is not a color format.
12710 - format is DEPTH_COMPONENT and the base internal format is not
12711 DEPTH_COMPONENT or DEPTH_STENCIL
12712 - format is DEPTH_STENCIL and the base internal format is not
12714 - format is STENCIL_INDEX and the base internal format is not
12715 STENCIL_INDEX or DEPTH_STENCIL
12716 - format is one of the integer formats in table 8.3 and the internal
12717 format of the texture image is not integer, or format is not one of
12718 the integer formats in table 8.3 and the internal format is integer. */
12719 gl.getTextureImage(texture_2D_stencil, 0, s_reference_format /* red */, s_reference_type, s_reference_size,
12721 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12722 "format is a color format (one of the formats in table 8.3 whose target is the color "
12723 "buffer) and the base internal format of the texture image is not a color format.");
12725 gl.getTextureImage(texture_2D, 0, GL_DEPTH_COMPONENT, s_reference_type, s_reference_size, store);
12726 is_ok &= CheckErrorAndLog(
12727 m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12728 "format is DEPTH_COMPONENT and the base internal format is not DEPTH_COMPONENT or DEPTH_STENCIL.");
12730 gl.getTextureImage(texture_2D, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, s_reference_size, store);
12731 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12732 "format is DEPTH_STENCIL and the base internal format is not DEPTH_STENCIL.");
12734 gl.getTextureImage(texture_2D, 0, GL_STENCIL_INDEX, s_reference_type, s_reference_size, store);
12735 is_ok &= CheckErrorAndLog(
12736 m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12737 "format is STENCIL_INDEX and the base internal format is not STENCIL_INDEX or DEPTH_STENCIL.");
12739 gl.getTextureImage(texture_2D, 0, GL_RED_INTEGER, s_reference_type, s_reference_size, store);
12740 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12741 "format is one of the integer formats in table 8.3 and the internal format of the "
12742 "texture image is not integer.");
12744 gl.getTextureImage(texture_2D_int, 0, GL_RED, s_reference_type, s_reference_size, store);
12745 is_ok &= CheckErrorAndLog(
12746 m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12747 "format is not one of the integer formats in table 8.3 and the internal format is integer.");
12749 /* Check that INVALID_OPERATION error is generated if a pixel pack buffer
12750 object is bound and packing the texture image into the buffer’s memory
12751 would exceed the size of the buffer. */
12752 gl.bindBuffer(GL_PIXEL_PACK_BUFFER, buffer);
12753 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
12755 gl.getTextureImage(texture_2D, 0, s_reference_format, s_reference_type, s_reference_size,
12756 (glw::GLuint*)NULL + 1);
12757 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12758 "a pixel pack buffer object is bound and packing the texture image into the buffer’s "
12759 "memory would exceed the size of the buffer.");
12761 gl.bindBuffer(GL_PIXEL_PACK_BUFFER, 0);
12762 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
12764 /* Check that INVALID_OPERATION error is generated if a pixel pack buffer
12765 object is bound and pixels is not evenly divisible by the number of
12766 basic machine units needed to store in memory the GL data type
12767 corresponding to type (see table 8.2). */
12768 gl.bindBuffer(GL_PIXEL_PACK_BUFFER, buffer);
12769 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
12771 gl.getTextureImage(texture_2D, 0, s_reference_format, s_reference_type, s_reference_size,
12772 (glw::GLubyte*)NULL + 1);
12773 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12774 "a pixel pack buffer object is bound and pixels is not evenly divisible by the "
12775 "number of basic machine units needed to store in memory the GL data type "
12776 "corresponding to type (see table 8.2).");
12778 gl.bindBuffer(GL_PIXEL_PACK_BUFFER, 0);
12779 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
12781 /* Check that INVALID_OPERATION error is generated by GetTextureImage if
12782 the buffer size required to store the requested data is greater than
12784 gl.getTextureImage(texture_2D, 0, s_reference_format, s_reference_type,
12785 s_reference_size - sizeof(s_reference_data[0]), store);
12786 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12787 "the buffer size required to store the requested data is greater than bufSize.");
12789 /* Check that INVALID_OPERATION is generated by GetCompressedTextureImage
12790 if texture is not the name of an existing texture object. */
12791 gl.getCompressedTextureImage(texture_invalid, 0, s_reference_size, store);
12792 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetCompressedTextureImage",
12793 "texture is not the name of an existing texture object.");
12795 /* Check that INVALID_VALUE is generated by GetCompressedTextureImage if
12796 level is less than zero or greater than the maximum number of LODs
12797 permitted by the implementation. */
12798 gl.getCompressedTextureImage(texture_2D_compressed, -1, s_reference_size, store);
12800 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glGetCompressedTextureImage", "level is less than zero.");
12802 gl.getCompressedTextureImage(texture_2D_compressed, max_level, s_reference_size, store);
12803 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glGetCompressedTextureImage",
12804 "level is greater than the maximum number of LODs permitted by the implementation.");
12806 /* Check that INVALID_OPERATION is generated if GetCompressedTextureImage
12807 is used to retrieve a texture that is in an uncompressed internal
12809 gl.getCompressedTextureImage(texture_2D, 0, s_reference_size, store);
12811 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetCompressedTextureImage",
12812 "the function is used to retrieve a texture that is in an uncompressed internal format.");
12814 /* Check that INVALID_OPERATION is generated by GetCompressedTextureImage
12815 if a non-zero buffer object name is bound to the PIXEL_PACK_BUFFER
12816 target, the buffer storage was not initialized with BufferStorage using
12817 MAP_PERSISTENT_BIT flag, and the buffer object's data store is currently
12819 gl.bindBuffer(GL_PIXEL_PACK_BUFFER, buffer);
12820 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
12822 gl.mapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_WRITE);
12824 if (GL_NO_ERROR == gl.getError())
12826 gl.getCompressedTextureImage(texture_2D_compressed, 0, s_reference_size, NULL);
12827 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetCompressedTextureImage",
12828 "a non-zero buffer object name is bound to the PIXEL_PACK_BUFFER target, the "
12829 "buffer storage was not initialized with BufferStorage using MAP_PERSISTENT_BIT "
12830 "flag, and the buffer object's data store is currently mapped.");
12832 gl.unmapBuffer(GL_PIXEL_PACK_BUFFER);
12833 GLU_EXPECT_NO_ERROR(gl.getError(), "glUnmapBuffer has failed");
12840 gl.bindBuffer(GL_PIXEL_PACK_BUFFER, 0);
12841 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
12843 /* Check that INVALID_OPERATION is generated by GetCompressedTextureImage
12844 if a non-zero buffer object name is bound to the PIXEL_PACK_BUFFER
12845 target and the data would be packed to the buffer object such that the
12846 memory writes required would exceed the data store size. */
12847 gl.bindBuffer(GL_PIXEL_PACK_BUFFER, buffer);
12848 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
12850 gl.getCompressedTextureImage(texture_2D_compressed, 0, s_reference_size, (char*)NULL + s_reference_size - 1);
12851 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetCompressedTextureImage",
12852 "a non-zero buffer object name is bound to the PIXEL_PACK_BUFFER target and the data "
12853 "would be packed to the buffer object such that the memory writes required would "
12854 "exceed the data store size.");
12856 gl.bindBuffer(GL_PIXEL_PACK_BUFFER, 0);
12857 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
12868 gl.deleteBuffers(1, &buffer);
12873 gl.deleteTextures(1, &texture_2D);
12876 if (texture_2D_int)
12878 gl.deleteTextures(1, &texture_2D_int);
12881 if (texture_2D_stencil)
12883 gl.deleteTextures(1, &texture_2D_stencil);
12888 gl.deleteTextures(1, &texture_2D_ms);
12891 if (texture_2D_compressed)
12893 gl.deleteTextures(1, &texture_2D_compressed);
12898 gl.deleteTextures(1, &texture_cube);
12901 if (texture_rectangle)
12903 gl.deleteTextures(1, &texture_rectangle);
12906 while (GL_NO_ERROR != gl.getError())
12909 /* Result's setup. */
12912 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
12918 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
12922 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
12929 /******************************** Level Parameter Query Errors Test Implementation ********************************/
12931 /** @brief Image Query Errors Test constructor.
12933 * @param [in] context OpenGL context.
12935 LevelParameterErrorsTest::LevelParameterErrorsTest(deqp::Context& context)
12936 : deqp::TestCase(context, "textures_level_parameter_errors", "Texture Level Parameter Query Errors Test")
12938 /* Intentionally left blank. */
12941 /** @brief Iterate Level Parameter Query Errors Test cases.
12943 * @return Iteration result.
12945 tcu::TestNode::IterateResult LevelParameterErrorsTest::iterate()
12947 /* Shortcut for GL functionality. */
12948 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
12950 /* Get context setup. */
12951 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
12952 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
12954 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
12956 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
12961 /* Running tests. */
12963 bool is_error = false;
12966 glw::GLuint texture_2D = 0;
12967 glw::GLuint texture_invalid = 0;
12968 glw::GLint max_level = 0;
12969 glw::GLenum pname_invalid = 0;
12971 glw::GLfloat storef[4] = {};
12972 glw::GLint storei[4] = {};
12976 /* Preparations. */
12979 gl.genTextures(1, &texture_2D);
12980 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
12982 gl.bindTexture(GL_TEXTURE_2D, texture_2D);
12983 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
12985 gl.texStorage2D(GL_TEXTURE_2D, 1, GL_R8, 1, 1);
12986 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
12989 gl.getIntegerv(GL_MAX_TEXTURE_SIZE, &max_level); /* assuming that x > log(x) */
12990 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
12992 /* invalid texture */
12993 while (gl.isTexture(++texture_invalid))
12996 /* invalid pname */
12997 glw::GLenum all_pnames[] = { GL_TEXTURE_WIDTH,
13000 GL_TEXTURE_SAMPLES,
13001 GL_TEXTURE_FIXED_SAMPLE_LOCATIONS,
13002 GL_TEXTURE_INTERNAL_FORMAT,
13003 GL_TEXTURE_RED_SIZE,
13004 GL_TEXTURE_GREEN_SIZE,
13005 GL_TEXTURE_BLUE_SIZE,
13006 GL_TEXTURE_ALPHA_SIZE,
13007 GL_TEXTURE_DEPTH_SIZE,
13008 GL_TEXTURE_STENCIL_SIZE,
13009 GL_TEXTURE_SHARED_SIZE,
13010 GL_TEXTURE_RED_TYPE,
13011 GL_TEXTURE_GREEN_TYPE,
13012 GL_TEXTURE_BLUE_TYPE,
13013 GL_TEXTURE_ALPHA_TYPE,
13014 GL_TEXTURE_DEPTH_TYPE,
13015 GL_TEXTURE_COMPRESSED,
13016 GL_TEXTURE_COMPRESSED_IMAGE_SIZE,
13017 GL_TEXTURE_BUFFER_DATA_STORE_BINDING,
13018 GL_TEXTURE_BUFFER_OFFSET,
13019 GL_TEXTURE_BUFFER_SIZE };
13021 glw::GLuint all_pnames_count = sizeof(all_pnames) / sizeof(all_pnames[0]);
13023 bool is_valid = true;
13031 for (glw::GLuint i = 0; i < all_pnames_count; ++i)
13033 if (all_pnames[i] == pname_invalid)
13044 /* Check that INVALID_OPERATION is generated by GetTextureLevelParameterfv
13045 and GetTextureLevelParameteriv functions if texture is not the name of
13046 an existing texture object. */
13047 gl.getTextureLevelParameterfv(texture_invalid, 0, GL_TEXTURE_WIDTH, storef);
13048 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureLevelParameterfv",
13049 "texture is not the name of an existing texture object.");
13051 gl.getTextureLevelParameteriv(texture_invalid, 0, GL_TEXTURE_WIDTH, storei);
13052 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureLevelParameteriv",
13053 "texture is not the name of an existing texture object.");
13055 /* Check that INVALID_VALUE is generated by GetTextureLevelParameter* if
13056 level is less than 0. */
13057 gl.getTextureLevelParameterfv(texture_2D, -1, GL_TEXTURE_WIDTH, storef);
13058 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glGetTextureLevelParameterfv", "level is less than 0.");
13060 gl.getTextureLevelParameteriv(texture_2D, -1, GL_TEXTURE_WIDTH, storei);
13061 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glGetTextureLevelParameteriv", "level is less than 0.");
13063 /* Check that INVALID_ENUM error is generated by GetTextureLevelParameter*
13064 if pname is not one of supported constants. */
13065 gl.getTextureLevelParameterfv(texture_2D, 0, pname_invalid, storef);
13066 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glGetTextureLevelParameterfv",
13067 "pname is not one of supported constants.");
13069 gl.getTextureLevelParameteriv(texture_2D, 0, pname_invalid, storei);
13070 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glGetTextureLevelParameteriv",
13071 "pname is not one of supported constants.");
13073 /* Check that INVALID_VALUE may be generated if level is greater than
13074 log2 max, where max is the returned value of MAX_TEXTURE_SIZE. */
13075 gl.getTextureLevelParameterfv(texture_2D, max_level, GL_TEXTURE_WIDTH, storef);
13077 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glGetTextureLevelParameterfv",
13078 "level is greater than log2 max, where max is the returned value of MAX_TEXTURE_SIZE.");
13080 gl.getTextureLevelParameteriv(texture_2D, max_level, GL_TEXTURE_WIDTH, storei);
13082 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glGetTextureLevelParameteriv",
13083 "level is greater than log2 max, where max is the returned value of MAX_TEXTURE_SIZE.");
13085 /* Check that INVALID_OPERATION is generated by GetTextureLevelParameter*
13086 if TEXTURE_COMPRESSED_IMAGE_SIZE is queried on texture images with an
13087 uncompressed internal format or on proxy targets. */
13088 gl.getTextureLevelParameterfv(texture_2D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, storef);
13089 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureLevelParameterfv",
13090 "TEXTURE_COMPRESSED_IMAGE_SIZE is queried on texture images with an uncompressed "
13091 "internal format or on proxy targets.");
13093 gl.getTextureLevelParameteriv(texture_2D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, storei);
13094 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureLevelParameteriv",
13095 "TEXTURE_COMPRESSED_IMAGE_SIZE is queried on texture images with an uncompressed "
13096 "internal format or on proxy targets.");
13107 gl.deleteTextures(1, &texture_2D);
13110 while (GL_NO_ERROR != gl.getError())
13113 /* Result's setup. */
13116 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
13122 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
13126 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
13133 /******************************** Parameter Query Errors Test Implementation ********************************/
13135 /** @brief Parameter Query Errors Test constructor.
13137 * @param [in] context OpenGL context.
13139 ParameterErrorsTest::ParameterErrorsTest(deqp::Context& context)
13140 : deqp::TestCase(context, "textures_parameter_errors", "Texture Parameter Query Errors Test")
13142 /* Intentionally left blank. */
13145 /** @brief Iterate Parameter Query Errors Test cases.
13147 * @return Iteration result.
13149 tcu::TestNode::IterateResult ParameterErrorsTest::iterate()
13151 /* Shortcut for GL functionality. */
13152 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
13154 /* Get context setup. */
13155 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
13156 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
13158 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
13160 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
13165 /* Running tests. */
13167 bool is_error = false;
13170 glw::GLuint texture_2D = 0;
13171 glw::GLuint texture_buffer = 0;
13172 glw::GLuint texture_invalid = 0;
13173 glw::GLenum pname_invalid = 0;
13175 glw::GLfloat storef[4] = {};
13176 glw::GLint storei[4] = {};
13177 glw::GLuint storeu[4] = {};
13181 /* Preparations. */
13184 gl.createTextures(GL_TEXTURE_2D, 1, &texture_2D);
13185 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
13187 /* Buffer texture */
13188 gl.createTextures(GL_TEXTURE_BUFFER, 1, &texture_buffer);
13189 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
13191 /* invalid texture */
13192 while (gl.isTexture(++texture_invalid))
13195 /* invalid pname */
13196 glw::GLenum all_pnames[] = { GL_IMAGE_FORMAT_COMPATIBILITY_TYPE,
13197 GL_TEXTURE_IMMUTABLE_FORMAT,
13198 GL_TEXTURE_IMMUTABLE_LEVELS,
13200 GL_TEXTURE_VIEW_MIN_LEVEL,
13201 GL_TEXTURE_VIEW_NUM_LEVELS,
13202 GL_TEXTURE_VIEW_MIN_LAYER,
13203 GL_TEXTURE_VIEW_NUM_LAYERS,
13204 GL_DEPTH_STENCIL_TEXTURE_MODE,
13205 GL_DEPTH_COMPONENT,
13207 GL_TEXTURE_BASE_LEVEL,
13208 GL_TEXTURE_BORDER_COLOR,
13209 GL_TEXTURE_COMPARE_MODE,
13210 GL_TEXTURE_COMPARE_FUNC,
13211 GL_TEXTURE_LOD_BIAS,
13212 GL_TEXTURE_MAG_FILTER,
13213 GL_TEXTURE_MAX_LEVEL,
13214 GL_TEXTURE_MAX_LOD,
13215 GL_TEXTURE_MIN_FILTER,
13216 GL_TEXTURE_MIN_LOD,
13217 GL_TEXTURE_SWIZZLE_R,
13218 GL_TEXTURE_SWIZZLE_G,
13219 GL_TEXTURE_SWIZZLE_B,
13220 GL_TEXTURE_SWIZZLE_A,
13221 GL_TEXTURE_SWIZZLE_RGBA,
13224 GL_TEXTURE_WRAP_R };
13226 glw::GLuint all_pnames_count = sizeof(all_pnames) / sizeof(all_pnames[0]);
13228 bool is_valid = true;
13236 for (glw::GLuint i = 0; i < all_pnames_count; ++i)
13238 if (all_pnames[i] == pname_invalid)
13249 /* Check that INVALID_ENUM is generated by glGetTextureParameter* if pname
13250 is not an accepted value. */
13251 gl.getTextureParameterfv(texture_2D, pname_invalid, storef);
13253 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glGetTextureParameterfv", "pname is not an accepted value.");
13255 gl.getTextureParameterIiv(texture_2D, pname_invalid, storei);
13257 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glGetTextureParameterIiv", "pname is not an accepted value.");
13259 gl.getTextureParameterIuiv(texture_2D, pname_invalid, storeu);
13260 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glGetTextureParameterIuiv",
13261 "pname is not an accepted value.");
13263 gl.getTextureParameteriv(texture_2D, pname_invalid, storei);
13265 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glGetTextureParameteriv", "pname is not an accepted value.");
13267 /* Check that INVALID_OPERATION is generated by glGetTextureParameter* if
13268 texture is not the name of an existing texture object. */
13269 gl.getTextureParameterfv(texture_invalid, GL_TEXTURE_TARGET, storef);
13270 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureParameterfv",
13271 "texture is not the name of an existing texture object.");
13273 gl.getTextureParameterIiv(texture_invalid, GL_TEXTURE_TARGET, storei);
13274 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureParameterIiv",
13275 "texture is not the name of an existing texture object.");
13277 gl.getTextureParameterIuiv(texture_invalid, GL_TEXTURE_TARGET, storeu);
13278 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureParameterIuiv",
13279 "texture is not the name of an existing texture object.");
13281 gl.getTextureParameteriv(texture_invalid, GL_TEXTURE_TARGET, storei);
13282 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureParameteriv",
13283 "texture is not the name of an existing texture object.");
13285 /* Check that INVALID_OPERATION error is generated if the effective target is
13286 not one of the supported texture targets (eg. TEXTURE_BUFFER). */
13287 gl.getTextureParameterfv(texture_buffer, GL_TEXTURE_TARGET, storef);
13289 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureParameterfv",
13290 "the effective target is not one of the supported texture targets (eg. TEXTURE_BUFFER).");
13292 gl.getTextureParameterIiv(texture_buffer, GL_TEXTURE_TARGET, storei);
13294 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureParameterIiv",
13295 "the effective target is not one of the supported texture targets (eg. TEXTURE_BUFFER).");
13297 gl.getTextureParameterIuiv(texture_buffer, GL_TEXTURE_TARGET, storeu);
13299 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureParameterIuiv",
13300 "the effective target is not one of the supported texture targets (eg. TEXTURE_BUFFER).");
13302 gl.getTextureParameteriv(texture_buffer, GL_TEXTURE_TARGET, storei);
13304 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureParameteriv",
13305 "the effective target is not one of the supported texture targets (eg. TEXTURE_BUFFER).");
13316 gl.deleteTextures(1, &texture_2D);
13319 if (texture_buffer)
13321 gl.deleteTextures(1, &texture_buffer);
13324 while (GL_NO_ERROR != gl.getError())
13327 /* Result's setup. */
13330 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
13336 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
13340 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
13347 } /* Textures namespace. */
13348 } /* DirectStateAccess namespace. */
13349 } /* gl4cts namespace. */