1 /*-------------------------------------------------------------------------
2 * OpenGL Conformance Test Suite
3 * -----------------------------
5 * Copyright (c) 2015-2016 The Khronos Group Inc.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 */ /*-------------------------------------------------------------------*/
26 * \file gl4cDirectStateAccessTexturesTests.cpp
27 * \brief Conformance tests for the Direct State Access feature functionality (Texture access part).
28 */ /*-----------------------------------------------------------------------------------------------------------*/
30 /* Uncomment this if SubImageErrorsTest crashes during negative test of TextureSubImage (negative value width/height/depth passed to the function). */
31 /* #define TURN_OFF_SUB_IMAGE_ERRORS_TEST_OF_NEGATIVE_WIDTH_HEIGHT_OR_DEPTH */
34 #include "gl4cDirectStateAccessTests.hpp"
36 #include "deSharedPtr.hpp"
38 #include "gluContextInfo.hpp"
39 #include "gluDefs.hpp"
40 #include "gluPixelTransfer.hpp"
41 #include "gluStrUtil.hpp"
43 #include "tcuFuzzyImageCompare.hpp"
44 #include "tcuImageCompare.hpp"
45 #include "tcuRenderTarget.hpp"
46 #include "tcuSurface.hpp"
47 #include "tcuTestLog.hpp"
50 #include "glwFunctions.hpp"
61 namespace DirectStateAccess
65 /******************************** Creation Test Implementation ********************************/
67 /** @brief Creation Test constructor.
69 * @param [in] context OpenGL context.
71 CreationTest::CreationTest(deqp::Context& context)
72 : deqp::TestCase(context, "textures_creation", "Texture Objects Creation Test")
74 /* Intentionally left blank. */
77 /** @brief Iterate Creation Test cases.
79 * @return Iteration result.
81 tcu::TestNode::IterateResult CreationTest::iterate()
83 /* Shortcut for GL functionality. */
84 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
86 /* Get context setup. */
87 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
88 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
90 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
92 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
99 bool is_error = false;
101 /* Textures' objects */
102 static const glw::GLenum texture_targets[] = { GL_TEXTURE_1D,
107 GL_TEXTURE_RECTANGLE,
109 GL_TEXTURE_CUBE_MAP_ARRAY,
111 GL_TEXTURE_2D_MULTISAMPLE,
112 GL_TEXTURE_2D_MULTISAMPLE_ARRAY };
113 static const glw::GLuint texture_targets_count = sizeof(texture_targets) / sizeof(texture_targets[0]);
114 static const glw::GLuint textures_count = 2;
116 glw::GLuint textures_legacy[textures_count] = {};
117 glw::GLuint textures_dsa[texture_targets_count][textures_count] = {};
121 /* Check legacy state creation. */
122 gl.genTextures(textures_count, textures_legacy);
123 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
125 for (glw::GLuint i = 0; i < textures_count; ++i)
127 if (gl.isTexture(textures_legacy[i]))
132 m_context.getTestContext().getLog()
133 << tcu::TestLog::Message
134 << "GenTextures has created default objects, but it should create only a names."
135 << tcu::TestLog::EndMessage;
139 /* Check direct state creation. */
140 for (glw::GLuint j = 0; j < texture_targets_count; ++j)
142 gl.createTextures(texture_targets[j], textures_count, textures_dsa[j]);
143 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
145 for (glw::GLuint i = 0; i < textures_count; ++i)
147 if (!gl.isTexture(textures_dsa[j][i]))
152 m_context.getTestContext().getLog()
153 << tcu::TestLog::Message << "CreateTextures has not created default objects for target "
154 << glu::getTextureTargetStr(texture_targets[j]) << "." << tcu::TestLog::EndMessage;
166 for (glw::GLuint i = 0; i < textures_count; ++i)
168 if (textures_legacy[i])
170 gl.deleteTextures(1, &textures_legacy[i]);
172 textures_legacy[i] = 0;
175 for (glw::GLuint j = 0; j < texture_targets_count; ++j)
177 if (textures_dsa[j][i])
179 gl.deleteTextures(1, &textures_dsa[j][i]);
181 textures_dsa[j][i] = 0;
186 /* Errors clean up. */
187 while (gl.getError())
190 /* Result's setup. */
193 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
199 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
203 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
210 /******************************** Reference Data Implementation *****************************/
212 /** @brief Internal Format selector.
215 * @tparam S Size (# of components).
216 * @tparam N Is normalized.
218 * @return Internal format.
221 glw::GLenum Reference::InternalFormat<glw::GLbyte, 1, false>()
227 glw::GLenum Reference::InternalFormat<glw::GLbyte, 2, false>()
233 glw::GLenum Reference::InternalFormat<glw::GLbyte, 3, false>()
239 glw::GLenum Reference::InternalFormat<glw::GLbyte, 4, false>()
245 glw::GLenum Reference::InternalFormat<glw::GLubyte, 1, false>()
251 glw::GLenum Reference::InternalFormat<glw::GLubyte, 2, false>()
257 glw::GLenum Reference::InternalFormat<glw::GLubyte, 3, false>()
263 glw::GLenum Reference::InternalFormat<glw::GLubyte, 4, false>()
269 glw::GLenum Reference::InternalFormat<glw::GLshort, 1, false>()
275 glw::GLenum Reference::InternalFormat<glw::GLshort, 2, false>()
281 glw::GLenum Reference::InternalFormat<glw::GLshort, 3, false>()
287 glw::GLenum Reference::InternalFormat<glw::GLshort, 4, false>()
293 glw::GLenum Reference::InternalFormat<glw::GLushort, 1, false>()
299 glw::GLenum Reference::InternalFormat<glw::GLushort, 2, false>()
305 glw::GLenum Reference::InternalFormat<glw::GLushort, 3, false>()
311 glw::GLenum Reference::InternalFormat<glw::GLushort, 4, false>()
317 glw::GLenum Reference::InternalFormat<glw::GLint, 1, false>()
323 glw::GLenum Reference::InternalFormat<glw::GLint, 2, false>()
329 glw::GLenum Reference::InternalFormat<glw::GLint, 3, false>()
335 glw::GLenum Reference::InternalFormat<glw::GLint, 4, false>()
341 glw::GLenum Reference::InternalFormat<glw::GLuint, 1, false>()
347 glw::GLenum Reference::InternalFormat<glw::GLuint, 2, false>()
353 glw::GLenum Reference::InternalFormat<glw::GLuint, 3, false>()
359 glw::GLenum Reference::InternalFormat<glw::GLuint, 4, false>()
365 glw::GLenum Reference::InternalFormat<glw::GLubyte, 1, true>()
371 glw::GLenum Reference::InternalFormat<glw::GLubyte, 2, true>()
377 glw::GLenum Reference::InternalFormat<glw::GLubyte, 3, true>()
383 glw::GLenum Reference::InternalFormat<glw::GLubyte, 4, true>()
389 glw::GLenum Reference::InternalFormat<glw::GLushort, 1, true>()
395 glw::GLenum Reference::InternalFormat<glw::GLushort, 2, true>()
401 glw::GLenum Reference::InternalFormat<glw::GLushort, 3, true>()
407 glw::GLenum Reference::InternalFormat<glw::GLushort, 4, true>()
413 glw::GLenum Reference::InternalFormat<glw::GLfloat, 1, true>()
419 glw::GLenum Reference::InternalFormat<glw::GLfloat, 2, true>()
425 glw::GLenum Reference::InternalFormat<glw::GLfloat, 3, true>()
431 glw::GLenum Reference::InternalFormat<glw::GLfloat, 4, true>()
436 /** @brief Format selector.
438 * @tparam S Size (# of components).
439 * @tparam N Is normalized.
444 glw::GLenum Reference::Format<1, false>()
446 return GL_RED_INTEGER;
450 glw::GLenum Reference::Format<2, false>()
452 return GL_RG_INTEGER;
456 glw::GLenum Reference::Format<3, false>()
458 return GL_RGB_INTEGER;
462 glw::GLenum Reference::Format<4, false>()
464 return GL_RGBA_INTEGER;
468 glw::GLenum Reference::Format<1, true>()
474 glw::GLenum Reference::Format<2, true>()
480 glw::GLenum Reference::Format<3, true>()
486 glw::GLenum Reference::Format<4, true>()
491 /** @brief Type selector.
498 glw::GLenum Reference::Type<glw::GLbyte>()
504 glw::GLenum Reference::Type<glw::GLubyte>()
506 return GL_UNSIGNED_BYTE;
510 glw::GLenum Reference::Type<glw::GLshort>()
516 glw::GLenum Reference::Type<glw::GLushort>()
518 return GL_UNSIGNED_SHORT;
522 glw::GLenum Reference::Type<glw::GLint>()
528 glw::GLenum Reference::Type<glw::GLuint>()
530 return GL_UNSIGNED_INT;
534 glw::GLenum Reference::Type<glw::GLfloat>()
539 /** @brief Reference data selector.
542 * @tparam N Is normalized.
544 * @return Reference data.
549 const glw::GLbyte* Reference::ReferenceData<glw::GLbyte, false>()
551 static const glw::GLbyte reference[s_reference_count] = {
552 0, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, -21, 22, -23,
553 24, -25, 26, -27, 28, -29, 30, -31, 32, -33, 34, -35, 36, -37, 38, -39, 40, -41, 42, -43, 44, -45, 46, -47,
554 48, -49, 50, -51, 52, -53, 54, -55, 56, -57, 58, -59, 60, -61, 62, -63, 64, -65, 66, -67, 68, -69, 70, -71,
555 72, -73, 74, -75, 76, -77, 78, -79, 80, -81, 82, -83, 84, -85, 86, -87, 88, -89, 90, -91, 92, -93, 94, -95
562 const glw::GLubyte* Reference::ReferenceData<glw::GLubyte, false>()
564 static const glw::GLubyte reference[s_reference_count] = {
565 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
566 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
567 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
568 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95
575 const glw::GLshort* Reference::ReferenceData<glw::GLshort, false>()
577 static const glw::GLshort reference[s_reference_count] = {
578 0, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, -21, 22, -23,
579 24, -25, 26, -27, 28, -29, 30, -31, 32, -33, 34, -35, 36, -37, 38, -39, 40, -41, 42, -43, 44, -45, 46, -47,
580 48, -49, 50, -51, 52, -53, 54, -55, 56, -57, 58, -59, 60, -61, 62, -63, 64, -65, 66, -67, 68, -69, 70, -71,
581 72, -73, 74, -75, 76, -77, 78, -79, 80, -81, 82, -83, 84, -85, 86, -87, 88, -89, 90, -91, 92, -93, 94, -95
588 const glw::GLushort* Reference::ReferenceData<glw::GLushort, false>()
590 static const glw::GLushort reference[s_reference_count] = {
591 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
592 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
593 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
594 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95
601 const glw::GLint* Reference::ReferenceData<glw::GLint, false>()
603 static const glw::GLint reference[s_reference_count] = {
604 0, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, -21, 22, -23,
605 24, -25, 26, -27, 28, -29, 30, -31, 32, -33, 34, -35, 36, -37, 38, -39, 40, -41, 42, -43, 44, -45, 46, -47,
606 48, -49, 50, -51, 52, -53, 54, -55, 56, -57, 58, -59, 60, -61, 62, -63, 64, -65, 66, -67, 68, -69, 70, -71,
607 72, -73, 74, -75, 76, -77, 78, -79, 80, -81, 82, -83, 84, -85, 86, -87, 88, -89, 90, -91, 92, -93, 94, -95
614 const glw::GLuint* Reference::ReferenceData<glw::GLuint, false>()
616 static const glw::GLuint reference[s_reference_count] = {
617 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
618 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
619 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
620 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95
627 const glw::GLubyte* Reference::ReferenceData<glw::GLubyte, true>()
629 static const glw::GLubyte reference[s_reference_count] = {
630 0, 2, 5, 8, 10, 13, 16, 18, 21, 24, 26, 29, 32, 34, 37, 40, 42, 45, 48, 51,
631 53, 56, 59, 61, 64, 67, 69, 72, 75, 77, 80, 83, 85, 88, 91, 93, 96, 99, 102, 104,
632 107, 110, 112, 115, 118, 120, 123, 126, 128, 131, 134, 136, 139, 142, 144, 147, 150, 153, 155, 158,
633 161, 163, 166, 169, 171, 174, 177, 179, 182, 185, 187, 190, 193, 195, 198, 201, 204, 206, 209, 212,
634 214, 217, 220, 222, 225, 228, 230, 233, 236, 238, 241, 244, 246, 249, 252, 255
641 const glw::GLushort* Reference::ReferenceData<glw::GLushort, true>()
643 static const glw::GLushort reference[s_reference_count] = {
644 0, 689, 1379, 2069, 2759, 3449, 4139, 4828, 5518, 6208, 6898, 7588, 8278, 8967, 9657, 10347,
645 11037, 11727, 12417, 13107, 13796, 14486, 15176, 15866, 16556, 17246, 17935, 18625, 19315, 20005, 20695, 21385,
646 22074, 22764, 23454, 24144, 24834, 25524, 26214, 26903, 27593, 28283, 28973, 29663, 30353, 31042, 31732, 32422,
647 33112, 33802, 34492, 35181, 35871, 36561, 37251, 37941, 38631, 39321, 40010, 40700, 41390, 42080, 42770, 43460,
648 44149, 44839, 45529, 46219, 46909, 47599, 48288, 48978, 49668, 50358, 51048, 51738, 52428, 53117, 53807, 54497,
649 55187, 55877, 56567, 57256, 57946, 58636, 59326, 60016, 60706, 61395, 62085, 62775, 63465, 64155, 64845, 65535
656 const glw::GLfloat* Reference::ReferenceData<glw::GLfloat, true>()
658 static const glw::GLfloat reference[s_reference_count] = {
659 0.f, 0.0105263158f, 0.0210526316f, 0.0315789474f, 0.0421052632f, 0.0526315789f,
660 0.0631578947f, 0.0736842105f, 0.0842105263f, 0.0947368421f, 0.1052631579f, 0.1157894737f,
661 0.1263157895f, 0.1368421053f, 0.1473684211f, 0.1578947368f, 0.1684210526f, 0.1789473684f,
662 0.1894736842f, 0.2f, 0.2105263158f, 0.2210526316f, 0.2315789474f, 0.2421052632f,
663 0.2526315789f, 0.2631578947f, 0.2736842105f, 0.2842105263f, 0.2947368421f, 0.3052631579f,
664 0.3157894737f, 0.3263157895f, 0.3368421053f, 0.3473684211f, 0.3578947368f, 0.3684210526f,
665 0.3789473684f, 0.3894736842f, 0.4f, 0.4105263158f, 0.4210526316f, 0.4315789474f,
666 0.4421052632f, 0.4526315789f, 0.4631578947f, 0.4736842105f, 0.4842105263f, 0.4947368421f,
667 0.5052631579f, 0.5157894737f, 0.5263157895f, 0.5368421053f, 0.5473684211f, 0.5578947368f,
668 0.5684210526f, 0.5789473684f, 0.5894736842f, 0.6f, 0.6105263158f, 0.6210526316f,
669 0.6315789474f, 0.6421052632f, 0.6526315789f, 0.6631578947f, 0.6736842105f, 0.6842105263f,
670 0.6947368421f, 0.7052631579f, 0.7157894737f, 0.7263157895f, 0.7368421053f, 0.7473684211f,
671 0.7578947368f, 0.7684210526f, 0.7789473684f, 0.7894736842f, 0.8f, 0.8105263158f,
672 0.8210526316f, 0.8315789474f, 0.8421052632f, 0.8526315789f, 0.8631578947f, 0.8736842105f,
673 0.8842105263f, 0.8947368421f, 0.9052631579f, 0.9157894737f, 0.9263157895f, 0.9368421053f,
674 0.9473684211f, 0.9578947368f, 0.9684210526f, 0.9789473684f, 0.9894736842f, 1.f
679 /* Total number of reference components. */
680 glw::GLuint Reference::ReferenceDataCount()
682 return s_reference_count;
685 /* Total number of reference size in basic machine units. */
686 template <typename T>
687 glw::GLuint Reference::ReferenceDataSize()
689 return Reference::ReferenceDataCount() * sizeof(T);
692 /** @brief Comparison function (for floats).
694 * @param [in] a First element.
695 * @param [in] b Second element.
697 * @return Comparison result.
700 bool Reference::Compare<glw::GLfloat>(const glw::GLfloat a, const glw::GLfloat b)
702 if (de::abs(a - b) < 1.f / 256.f)
709 /** @brief Comparison function (integer).
711 * @param [in] a First element.
712 * @param [in] b Second element.
714 * @return Comparison result.
716 template <typename T>
717 bool Reference::Compare(const T a, const T b)
722 /******************************** Buffer Test Implementation ********************************/
724 /** @brief Buffer Test constructor.
728 * @tparam N Is normalized.
730 * @param [in] context OpenGL context.
731 * @param [in] name Name of the test.
733 template <typename T, glw::GLint S, bool N>
734 BufferTest<T, S, N>::BufferTest(deqp::Context& context, const char* name)
735 : deqp::TestCase(context, name, "Texture Buffer Objects Test")
743 /* Intentionally left blank. */
746 /** @brief Count of reference data to be teted.
750 template <typename T, glw::GLint S, bool N>
751 glw::GLuint BufferTest<T, S, N>::TestReferenceDataCount()
753 return s_fbo_size_x * S;
756 /** @brief Size of reference data to be teted..
760 template <typename T, glw::GLint S, bool N>
761 glw::GLuint BufferTest<T, S, N>::TestReferenceDataSize()
763 return static_cast<glw::GLint>(TestReferenceDataCount() * sizeof(T));
766 /** @brief Create buffer textuew.
768 * @param [in] use_range_version Uses TextureBufferRange instead TextureBuffer.
770 * @return True if succeded, false otherwise.
772 template <typename T, glw::GLint S, bool N>
773 bool BufferTest<T, S, N>::CreateBufferTexture(bool use_range_version)
775 /* Shortcut for GL functionality. */
776 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
778 /* Objects creation. */
779 gl.genTextures(1, &m_to);
780 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
782 gl.bindTexture(GL_TEXTURE_BUFFER, m_to);
783 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
785 gl.genBuffers(1, &m_bo);
786 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateBuffers has failed");
788 gl.bindBuffer(GL_TEXTURE_BUFFER, m_bo);
789 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
792 if (use_range_version)
794 glw::GLint alignment = 1;
796 gl.getIntegerv(GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT, &alignment);
797 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
799 const glw::GLuint b_offset = alignment;
800 const glw::GLuint b_size = TestReferenceDataSize() + b_offset;
802 gl.bufferData(GL_TEXTURE_BUFFER, b_size, NULL, GL_STATIC_DRAW);
803 GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData has failed");
805 gl.bufferSubData(GL_TEXTURE_BUFFER, b_offset, TestReferenceDataSize(), ReferenceData<T, N>());
806 GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferSubdata has failed");
808 gl.textureBufferRange(m_to, InternalFormat<T, S, N>(), m_bo, b_offset, TestReferenceDataSize());
812 gl.bufferData(GL_TEXTURE_BUFFER, TestReferenceDataSize(), ReferenceData<T, N>(), GL_STATIC_DRAW);
813 GLU_EXPECT_NO_ERROR(gl.getError(), "glNamedBufferData has failed");
815 gl.textureBuffer(m_to, InternalFormat<T, S, N>(), m_bo);
818 /* Error checking. */
821 if (GL_NO_ERROR != (error = gl.getError()))
824 m_context.getTestContext().getLog()
825 << tcu::TestLog::Message << (use_range_version ? ("glTextureBufferRange") : ("glTextureBuffer"))
826 << " unexpectedly generated error " << glu::getErrorStr(error) << " during test of internal format "
827 << glu::getTextureFormatStr(InternalFormat<T, S, N>()) << "." << tcu::TestLog::EndMessage;
829 CleanBufferTexture();
837 /** @brief Function prepares framebuffer with internal format color attachment.
838 * Viewport is set up. Content of the framebuffer is cleared.
840 * @note The function may throw if unexpected error has occured.
842 * @return if the framebuffer returned is supported
844 template <typename T, glw::GLint S, bool N>
845 bool BufferTest<T, S, N>::PrepareFramebuffer(const glw::GLenum internal_format)
847 /* Shortcut for GL functionality. */
848 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
850 /* Prepare framebuffer. */
851 gl.genFramebuffers(1, &m_fbo);
852 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
854 gl.genRenderbuffers(1, &m_rbo);
855 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
857 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
858 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
860 gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo);
861 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
863 gl.renderbufferStorage(GL_RENDERBUFFER, internal_format, s_fbo_size_x, s_fbo_size_y);
864 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage call failed.");
866 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo);
867 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer call failed.");
869 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
871 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_UNSUPPORTED)
872 throw tcu::NotSupportedError("unsupported framebuffer configuration");
877 gl.viewport(0, 0, s_fbo_size_x, s_fbo_size_y);
878 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
880 /* Clear framebuffer's content. */
881 gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
882 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor call failed.");
884 gl.clear(GL_COLOR_BUFFER_BIT);
885 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear call failed.");
890 /** @brief Create program.
892 * @param [in] variable_declaration Choose variable declaration of the fragment shader.
894 template <typename T, glw::GLint S, bool N>
895 void BufferTest<T, S, N>::PrepareProgram(const glw::GLchar* variable_declaration)
897 /* Shortcut for GL functionality */
898 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
902 glw::GLchar const* source[3];
903 glw::GLsizei const count;
904 glw::GLenum const type;
907 { { s_vertex_shader, NULL, NULL }, 1, GL_VERTEX_SHADER, 0 },
908 { { s_fragment_shader_head, variable_declaration, s_fragment_shader_tail }, 3, GL_FRAGMENT_SHADER, 0 }
911 glw::GLuint const shader_count = sizeof(shader) / sizeof(shader[0]);
915 /* Create program. */
916 m_po = gl.createProgram();
917 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateProgram call failed.");
919 /* Shader compilation. */
921 for (glw::GLuint i = 0; i < shader_count; ++i)
924 shader[i].id = gl.createShader(shader[i].type);
926 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateShader call failed.");
928 gl.attachShader(m_po, shader[i].id);
930 GLU_EXPECT_NO_ERROR(gl.getError(), "glAttachShader call failed.");
932 gl.shaderSource(shader[i].id, shader[i].count, shader[i].source, NULL);
934 GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource call failed.");
936 gl.compileShader(shader[i].id);
938 GLU_EXPECT_NO_ERROR(gl.getError(), "glCompileShader call failed.");
940 glw::GLint status = GL_FALSE;
942 gl.getShaderiv(shader[i].id, GL_COMPILE_STATUS, &status);
943 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv call failed.");
945 if (GL_FALSE == status)
947 glw::GLint log_size = 0;
948 gl.getShaderiv(shader[i].id, GL_INFO_LOG_LENGTH, &log_size);
949 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv call failed.");
951 glw::GLchar* log_text = new glw::GLchar[log_size];
953 gl.getShaderInfoLog(shader[i].id, log_size, NULL, &log_text[0]);
955 m_context.getTestContext().getLog()
956 << tcu::TestLog::Message << "Shader compilation has failed.\n"
957 << "Shader type: " << glu::getShaderTypeStr(shader[i].type) << "\n"
958 << "Shader compilation error log:\n"
960 << "Shader source code:\n"
961 << shader[i].source[0] << (shader[i].source[1] ? shader[i].source[1] : "")
962 << (shader[i].source[2] ? shader[i].source[2] : "") << "\n"
963 << tcu::TestLog::EndMessage;
967 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderInfoLog call failed.");
975 gl.linkProgram(m_po);
977 GLU_EXPECT_NO_ERROR(gl.getError(), "glTransformFeedbackVaryings call failed.");
979 glw::GLint status = GL_FALSE;
981 gl.getProgramiv(m_po, GL_LINK_STATUS, &status);
983 if (GL_TRUE == status)
985 for (glw::GLuint i = 0; i < shader_count; ++i)
989 gl.detachShader(m_po, shader[i].id);
991 GLU_EXPECT_NO_ERROR(gl.getError(), "glDetachShader call failed.");
997 glw::GLint log_size = 0;
999 gl.getProgramiv(m_po, GL_INFO_LOG_LENGTH, &log_size);
1001 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramiv call failed.");
1003 glw::GLchar* log_text = new glw::GLchar[log_size];
1005 gl.getProgramInfoLog(m_po, log_size, NULL, &log_text[0]);
1007 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Program linkage has failed due to:\n"
1009 << tcu::TestLog::EndMessage;
1013 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramInfoLog call failed.");
1022 gl.deleteProgram(m_po);
1028 for (glw::GLuint i = 0; i < shader_count; ++i)
1030 if (0 != shader[i].id)
1032 gl.deleteShader(shader[i].id);
1044 /** @brief Create VAO.
1046 template <typename T, glw::GLint S, bool N>
1047 void BufferTest<T, S, N>::PrepareVertexArray()
1049 /* Shortcut for GL functionality. */
1050 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1052 gl.genVertexArrays(1, &m_vao);
1053 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays has failed");
1055 gl.bindVertexArray(m_vao);
1056 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray has failed");
1059 /** @brief Test's draw function.
1061 template <typename T, glw::GLint S, bool N>
1062 void BufferTest<T, S, N>::Draw()
1064 /* Shortcut for GL functionality. */
1065 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1067 gl.useProgram(m_po);
1068 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram has failed");
1070 gl.activeTexture(GL_TEXTURE0);
1071 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
1073 gl.bindTextureUnit(0, m_to);
1074 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
1076 gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
1077 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays has failed");
1080 /** @brief Compre results with the reference.
1082 * @return True if equal, false otherwise.
1084 template <typename T, glw::GLint S, bool N>
1085 bool BufferTest<T, S, N>::Check()
1087 /* Shortcut for GL functionality. */
1088 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1090 /* Fetching data. */
1091 std::vector<T> result(TestReferenceDataCount());
1093 gl.pixelStorei(GL_UNPACK_ALIGNMENT, sizeof(T));
1094 GLU_EXPECT_NO_ERROR(gl.getError(), "glPixelStorei has failed");
1096 gl.pixelStorei(GL_PACK_ALIGNMENT, sizeof(T));
1097 GLU_EXPECT_NO_ERROR(gl.getError(), "glPixelStorei has failed");
1099 gl.readnPixels(0, 0, s_fbo_size_x, s_fbo_size_y, Format<S, N>(), Type<T>(), TestReferenceDataSize(),
1100 (glw::GLvoid*)(&result[0]));
1101 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels has failed");
1106 for (glw::GLuint i = 0; i < TestReferenceDataCount(); ++i)
1108 if (!Compare<T>(result[i], ReferenceData<T, N>()[i]))
1119 /** @brief Test function.
1121 * @param [in] use_range_version Uses TextureBufferRange instead TextureBuffer.
1123 * @return True if succeeded, false otherwise.
1125 template <typename T, glw::GLint S, bool N>
1126 bool BufferTest<T, S, N>::Test(bool use_range_version)
1129 if (!PrepareFramebuffer(InternalFormat<T, S, N>()))
1132 * If the framebuffer it not supported, means that the
1133 * tested combination is unsupported for this driver,
1134 * but allowed to be unsupported by OpenGL spec, so we
1143 if (!CreateBufferTexture(use_range_version))
1154 /* Compare results with reference. */
1155 bool result = Check();
1159 CleanBufferTexture();
1166 /** @brief Clean GL objects
1168 template <typename T, glw::GLint S, bool N>
1169 void BufferTest<T, S, N>::CleanBufferTexture()
1171 /* Shortcut for GL functionality. */
1172 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1177 gl.deleteTextures(1, &m_to);
1182 /* Texture buffer. */
1185 gl.deleteBuffers(1, &m_bo);
1191 /** @brief Clean GL objects
1193 template <typename T, glw::GLint S, bool N>
1194 void BufferTest<T, S, N>::CleanFramebuffer()
1196 /* Shortcut for GL functionality. */
1197 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1202 gl.deleteFramebuffers(1, &m_fbo);
1210 gl.deleteRenderbuffers(1, &m_rbo);
1216 /** @brief Clean GL objects
1218 template <typename T, glw::GLint S, bool N>
1219 void BufferTest<T, S, N>::CleanProgram()
1221 /* Shortcut for GL functionality. */
1222 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1229 gl.deleteProgram(m_po);
1235 /** @brief Clean errors.
1237 template <typename T, glw::GLint S, bool N>
1238 void BufferTest<T, S, N>::CleanErrors()
1240 /* Shortcut for GL functionality. */
1241 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1243 /* Query all errors until GL_NO_ERROR occure. */
1244 while (GL_NO_ERROR != gl.getError())
1248 /** @brief Clean GL objects
1250 template <typename T, glw::GLint S, bool N>
1251 void BufferTest<T, S, N>::CleanVertexArray()
1253 /* Shortcut for GL functionality. */
1254 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1258 gl.bindVertexArray(0);
1260 gl.deleteVertexArrays(1, &m_vao);
1266 /** @brief Iterate Buffer Test cases.
1268 * @return Iteration result.
1270 template <typename T, glw::GLint S, bool N>
1271 tcu::TestNode::IterateResult BufferTest<T, S, N>::iterate()
1273 /* Shortcut for GL functionality. */
1274 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1276 /* Get context setup. */
1277 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
1278 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
1280 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
1282 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
1287 /* Running tests. */
1289 bool is_error = false;
1293 PrepareVertexArray();
1295 PrepareProgram(FragmentShaderDeclaration());
1297 for (glw::GLuint i = 0; i < 2; ++i)
1299 bool use_range = (i == 1);
1300 is_ok &= Test(use_range);
1306 catch (tcu::NotSupportedError e)
1317 CleanBufferTexture();
1323 /* Errors clean up. */
1324 while (gl.getError())
1327 /* Result's setup. */
1330 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1336 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
1340 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
1347 /* Vertex shader source code. */
1348 template <typename T, glw::GLint S, bool N>
1349 const glw::GLchar* BufferTest<T, S, N>::s_vertex_shader = "#version 450\n"
1353 " switch(gl_VertexID)\n"
1356 " gl_Position = vec4(-1.0, 1.0, 0.0, 1.0);\n"
1359 " gl_Position = vec4( 1.0, 1.0, 0.0, 1.0);\n"
1362 " gl_Position = vec4(-1.0,-1.0, 0.0, 1.0);\n"
1365 " gl_Position = vec4( 1.0,-1.0, 0.0, 1.0);\n"
1370 /* Fragment shader source program. */
1371 template <typename T, glw::GLint S, bool N>
1372 const glw::GLchar* BufferTest<T, S, N>::s_fragment_shader_head = "#version 450\n"
1374 "layout(pixel_center_integer) in vec4 gl_FragCoord;\n"
1377 template <typename T, glw::GLint S, bool N>
1378 const glw::GLchar* BufferTest<T, S, N>::s_fragment_shader_fdecl_lowp = "uniform samplerBuffer texture_input;\n"
1379 "out vec4 texture_output;\n";
1381 template <typename T, glw::GLint S, bool N>
1382 const glw::GLchar* BufferTest<T, S, N>::s_fragment_shader_idecl_lowp = "uniform isamplerBuffer texture_input;\n"
1383 "out ivec4 texture_output;\n";
1385 template <typename T, glw::GLint S, bool N>
1386 const glw::GLchar* BufferTest<T, S, N>::s_fragment_shader_udecl_lowp = "uniform usamplerBuffer texture_input;\n"
1387 "out uvec4 texture_output;\n";
1389 template <typename T, glw::GLint S, bool N>
1390 const glw::GLchar* BufferTest<T, S, N>::s_fragment_shader_fdecl_mediump = "uniform samplerBuffer texture_input;\n"
1391 "out vec4 texture_output;\n";
1393 template <typename T, glw::GLint S, bool N>
1394 const glw::GLchar* BufferTest<T, S, N>::s_fragment_shader_idecl_mediump = "uniform isamplerBuffer texture_input;\n"
1395 "out ivec4 texture_output;\n";
1397 template <typename T, glw::GLint S, bool N>
1398 const glw::GLchar* BufferTest<T, S, N>::s_fragment_shader_udecl_mediump = "uniform usamplerBuffer texture_input;\n"
1399 "out uvec4 texture_output;\n";
1401 template <typename T, glw::GLint S, bool N>
1402 const glw::GLchar* BufferTest<T, S, N>::s_fragment_shader_fdecl_highp = "uniform samplerBuffer texture_input;\n"
1403 "out vec4 texture_output;\n";
1405 template <typename T, glw::GLint S, bool N>
1406 const glw::GLchar* BufferTest<T, S, N>::s_fragment_shader_idecl_highp = "uniform isamplerBuffer texture_input;\n"
1407 "out ivec4 texture_output;\n";
1409 template <typename T, glw::GLint S, bool N>
1410 const glw::GLchar* BufferTest<T, S, N>::s_fragment_shader_udecl_highp = "uniform usamplerBuffer texture_input;\n"
1411 "out uvec4 texture_output;\n";
1413 template <typename T, glw::GLint S, bool N>
1414 const glw::GLchar* BufferTest<T, S, N>::s_fragment_shader_tail =
1418 " texture_output = texelFetch(texture_input, int(gl_FragCoord.x));\n"
1421 template class BufferTest<glw::GLbyte, 1, false>;
1422 template class BufferTest<glw::GLbyte, 2, false>;
1423 template class BufferTest<glw::GLbyte, 4, false>;
1425 template class BufferTest<glw::GLubyte, 1, false>;
1426 template class BufferTest<glw::GLubyte, 2, false>;
1427 template class BufferTest<glw::GLubyte, 4, false>;
1428 template class BufferTest<glw::GLubyte, 1, true>;
1429 template class BufferTest<glw::GLubyte, 2, true>;
1430 template class BufferTest<glw::GLubyte, 4, true>;
1432 template class BufferTest<glw::GLshort, 1, false>;
1433 template class BufferTest<glw::GLshort, 2, false>;
1434 template class BufferTest<glw::GLshort, 4, false>;
1436 template class BufferTest<glw::GLushort, 1, false>;
1437 template class BufferTest<glw::GLushort, 2, false>;
1438 template class BufferTest<glw::GLushort, 4, false>;
1439 template class BufferTest<glw::GLushort, 1, true>;
1440 template class BufferTest<glw::GLushort, 2, true>;
1441 template class BufferTest<glw::GLushort, 4, true>;
1443 template class BufferTest<glw::GLint, 1, false>;
1444 template class BufferTest<glw::GLint, 2, false>;
1445 template class BufferTest<glw::GLint, 3, false>;
1446 template class BufferTest<glw::GLint, 4, false>;
1448 template class BufferTest<glw::GLuint, 1, false>;
1449 template class BufferTest<glw::GLuint, 2, false>;
1450 template class BufferTest<glw::GLuint, 3, false>;
1451 template class BufferTest<glw::GLuint, 4, false>;
1453 template class BufferTest<glw::GLfloat, 1, true>;
1454 template class BufferTest<glw::GLfloat, 2, true>;
1455 template class BufferTest<glw::GLfloat, 3, true>;
1456 template class BufferTest<glw::GLfloat, 4, true>;
1458 /******************************** Storage and SubImage Test Implementation ********************************/
1460 /** @brief Storage Test constructor.
1462 * @param [in] context OpenGL context.
1464 StorageAndSubImageTest::StorageAndSubImageTest(deqp::Context& context)
1465 : deqp::TestCase(context, "textures_storage_and_subimage", "Texture Storage and SubImage Test")
1472 /* Intentionally left blank. */
1475 /** @brief Count of reference data to be teted.
1477 * @tparam S Size (# of components).
1478 * @tparam D Texture dimenisons.
1482 template <glw::GLint S, glw::GLuint D>
1483 glw::GLuint StorageAndSubImageTest::TestReferenceDataCount()
1485 return 2 /* 1D */ * ((D > 1) ? 3 : 1) /* 2D */ * ((D > 2) ? 4 : 1) /* 3D */ * S /* components */;
1488 /** @brief Size of reference data to be teted.
1491 * @tparam S Size (# of components).
1492 * @tparam D Texture dimenisons.
1496 template <typename T, glw::GLint S, glw::GLuint D>
1497 glw::GLuint StorageAndSubImageTest::TestReferenceDataSize()
1499 return static_cast<glw::GLint>(TestReferenceDataCount<S, D>() * sizeof(T));
1502 /** @brief Height, width or depth of reference data to be teted.
1504 * @tparam D Texture dimenisons.
1506 * @return Height, width or depth.
1509 glw::GLuint StorageAndSubImageTest::TestReferenceDataHeight<2>()
1515 glw::GLuint StorageAndSubImageTest::TestReferenceDataHeight<3>()
1521 glw::GLuint StorageAndSubImageTest::TestReferenceDataDepth<3>()
1526 template <glw::GLuint D>
1527 glw::GLuint StorageAndSubImageTest::TestReferenceDataWidth()
1532 template <glw::GLuint D>
1533 glw::GLuint StorageAndSubImageTest::TestReferenceDataHeight()
1538 template <glw::GLuint D>
1539 glw::GLuint StorageAndSubImageTest::TestReferenceDataDepth()
1544 /** @brief Fragment shader declaration selector.
1547 * @tparam N Normalized flag.
1548 * @tparam D Texture dimenisons.
1550 * @return Frgment shader source code part.
1553 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLbyte, false, 1>()
1555 return s_fragment_shader_1D_fdecl_lowp;
1559 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLubyte, false, 1>()
1561 return s_fragment_shader_1D_idecl_lowp;
1565 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLshort, false, 1>()
1567 return s_fragment_shader_1D_udecl_lowp;
1571 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLushort, false, 1>()
1573 return s_fragment_shader_1D_fdecl_mediump;
1577 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLint, false, 1>()
1579 return s_fragment_shader_1D_idecl_mediump;
1583 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLuint, false, 1>()
1585 return s_fragment_shader_1D_udecl_mediump;
1589 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLubyte, true, 1>()
1591 return s_fragment_shader_1D_fdecl_highp;
1595 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLushort, true, 1>()
1597 return s_fragment_shader_1D_idecl_highp;
1601 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLfloat, true, 1>()
1603 return s_fragment_shader_1D_udecl_highp;
1607 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLbyte, false, 2>()
1609 return s_fragment_shader_2D_fdecl_lowp;
1613 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLubyte, false, 2>()
1615 return s_fragment_shader_2D_idecl_lowp;
1619 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLshort, false, 2>()
1621 return s_fragment_shader_2D_udecl_lowp;
1625 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLushort, false, 2>()
1627 return s_fragment_shader_2D_fdecl_mediump;
1631 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLint, false, 2>()
1633 return s_fragment_shader_2D_idecl_mediump;
1637 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLuint, false, 2>()
1639 return s_fragment_shader_2D_udecl_mediump;
1643 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLubyte, true, 2>()
1645 return s_fragment_shader_2D_fdecl_highp;
1649 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLushort, true, 2>()
1651 return s_fragment_shader_2D_idecl_highp;
1655 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLfloat, true, 2>()
1657 return s_fragment_shader_2D_udecl_highp;
1661 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLbyte, false, 3>()
1663 return s_fragment_shader_3D_fdecl_lowp;
1667 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLubyte, false, 3>()
1669 return s_fragment_shader_3D_idecl_lowp;
1673 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLshort, false, 3>()
1675 return s_fragment_shader_3D_udecl_lowp;
1679 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLushort, false, 3>()
1681 return s_fragment_shader_3D_fdecl_mediump;
1685 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLint, false, 3>()
1687 return s_fragment_shader_3D_idecl_mediump;
1691 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLuint, false, 3>()
1693 return s_fragment_shader_3D_udecl_mediump;
1697 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLubyte, true, 3>()
1699 return s_fragment_shader_3D_fdecl_highp;
1703 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLushort, true, 3>()
1705 return s_fragment_shader_3D_idecl_highp;
1709 const glw::GLchar* StorageAndSubImageTest::FragmentShaderDeclaration<glw::GLfloat, true, 3>()
1711 return s_fragment_shader_3D_udecl_highp;
1714 /** @brief Fragment shader tail selector.
1716 * @tparam D Texture dimenisons.
1718 * @return Frgment shader source code part.
1721 const glw::GLchar* StorageAndSubImageTest::FragmentShaderTail<1>()
1723 return s_fragment_shader_1D_tail;
1727 const glw::GLchar* StorageAndSubImageTest::FragmentShaderTail<2>()
1729 return s_fragment_shader_2D_tail;
1733 const glw::GLchar* StorageAndSubImageTest::FragmentShaderTail<3>()
1735 return s_fragment_shader_3D_tail;
1738 /** @brief Texture target selector.
1740 * @tparam D Texture dimenisons.
1742 * @return Texture target.
1745 glw::GLenum StorageAndSubImageTest::TextureTarget<1>()
1747 return GL_TEXTURE_1D;
1751 glw::GLenum StorageAndSubImageTest::TextureTarget<2>()
1753 return GL_TEXTURE_2D;
1757 glw::GLenum StorageAndSubImageTest::TextureTarget<3>()
1759 return GL_TEXTURE_3D;
1762 /** @brief TextureStorage* wrapper.
1764 * @tparam D Texture dimenisons.
1765 * @tparam I Select between legacy/DSA way.
1767 * @return true if suuceed (in legacy always or throw), false otherwise.
1770 bool StorageAndSubImageTest::TextureStorage<1, true>(glw::GLenum target, glw::GLuint texture, glw::GLsizei levels,
1771 glw::GLenum internalformat, glw::GLsizei width,
1772 glw::GLsizei height, glw::GLsizei depth)
1777 /* Shortcut for GL functionality. */
1778 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1780 /* Preparing storage. */
1781 gl.texStorage1D(target, levels, internalformat, width);
1782 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage1D has failed");
1784 /* TextureSubImage* (not TextureStorage*) is tested so here we only throw when error occurs. */
1788 /** @brief TextureStorage* wrapper.
1790 * @tparam D Texture dimenisons.
1791 * @tparam I Select between legacy/DSA way.
1793 * @return true if suuceed (in legacy always or throw), false otherwise.
1796 bool StorageAndSubImageTest::TextureStorage<2, true>(glw::GLenum target, glw::GLuint texture, glw::GLsizei levels,
1797 glw::GLenum internalformat, glw::GLsizei width,
1798 glw::GLsizei height, glw::GLsizei depth)
1802 /* Shortcut for GL functionality. */
1803 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1805 /* Preparing storage. */
1806 gl.texStorage2D(target, levels, internalformat, width, height);
1807 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage2D has failed");
1809 /* TextureSubImage* (not TextureStorage*) is tested so here we only throw when error occurs. */
1813 /** @brief TextureStorage* wrapper.
1815 * @tparam D Texture dimenisons.
1816 * @tparam I Select between legacy/DSA way.
1818 * @return true if suuceed (in legacy always or throw), false otherwise.
1821 bool StorageAndSubImageTest::TextureStorage<3, true>(glw::GLenum target, glw::GLuint texture, glw::GLsizei levels,
1822 glw::GLenum internalformat, glw::GLsizei width,
1823 glw::GLsizei height, glw::GLsizei depth)
1826 /* Shortcut for GL functionality. */
1827 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1829 /* Preparing storage. */
1830 gl.texStorage3D(target, levels, internalformat, width, height, depth);
1831 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage3D has failed");
1833 /* TextureSubImage* (not TextureStorage*) is tested so here we only throw when error occurs. */
1837 /** @brief TextureStorage* wrapper.
1839 * @tparam D Texture dimenisons.
1840 * @tparam I Select between legacy/DSA way.
1842 * @return true if suuceed (in legacy always or throw), false otherwise.
1845 bool StorageAndSubImageTest::TextureStorage<1, false>(glw::GLenum target, glw::GLuint texture, glw::GLsizei levels,
1846 glw::GLenum internalformat, glw::GLsizei width,
1847 glw::GLsizei height, glw::GLsizei depth)
1852 /* Shortcut for GL functionality. */
1853 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1855 /* Preparing storage. */
1856 gl.textureStorage1D(texture, levels, internalformat, width);
1858 /* Error checking. */
1861 if (GL_NO_ERROR != (error = gl.getError()))
1864 m_context.getTestContext().getLog()
1865 << tcu::TestLog::Message << "glTextureStorage1D unexpectedly generated error " << glu::getErrorStr(error)
1866 << " during test with levels " << levels << ", internal format " << internalformat << " and width " << width
1867 << "." << tcu::TestLog::EndMessage;
1878 /** @brief TextureStorage* wrapper.
1880 * @tparam D Texture dimenisons.
1881 * @tparam I Select between legacy/DSA way.
1883 * @return true if suuceed (in legacy always or throw), false otherwise.
1886 bool StorageAndSubImageTest::TextureStorage<2, false>(glw::GLenum target, glw::GLuint texture, glw::GLsizei levels,
1887 glw::GLenum internalformat, glw::GLsizei width,
1888 glw::GLsizei height, glw::GLsizei depth)
1892 /* Shortcut for GL functionality. */
1893 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1895 /* Preparing storage. */
1896 gl.textureStorage2D(texture, levels, internalformat, width, height);
1898 /* Error checking. */
1901 if (GL_NO_ERROR != (error = gl.getError()))
1904 m_context.getTestContext().getLog()
1905 << tcu::TestLog::Message << "glTextureStorage2D unexpectedly generated error " << glu::getErrorStr(error)
1906 << " during test with levels " << levels << ", internal format " << internalformat << ", width " << width
1907 << " and height " << height << "." << tcu::TestLog::EndMessage;
1918 /** @brief TextureStorage* wrapper.
1920 * @tparam D Texture dimenisons.
1921 * @tparam I Select between legacy/DSA way.
1923 * @return true if suuceed (in legacy always or throw), false otherwise.
1926 bool StorageAndSubImageTest::TextureStorage<3, false>(glw::GLenum target, glw::GLuint texture, glw::GLsizei levels,
1927 glw::GLenum internalformat, glw::GLsizei width,
1928 glw::GLsizei height, glw::GLsizei depth)
1931 /* Shortcut for GL functionality. */
1932 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1934 /* Preparing storage. */
1935 gl.textureStorage3D(texture, levels, internalformat, width, height, depth);
1937 /* Error checking. */
1940 if (GL_NO_ERROR != (error = gl.getError()))
1943 m_context.getTestContext().getLog()
1944 << tcu::TestLog::Message << "glTextureStorage3D unexpectedly generated error " << glu::getErrorStr(error)
1945 << " during test with levels " << levels << ", internal format " << glu::getTextureFormatStr(internalformat)
1946 << ", width " << width << ", height " << height << " and depth " << depth << "."
1947 << tcu::TestLog::EndMessage;
1958 /** @brief TextureSubImage* wrapper.
1960 * @tparam D Texture dimenisons.
1961 * @tparam I Select between legacy/DSA way.
1963 * @return true if suuceed (in legacy always or throw), false otherwise.
1966 bool StorageAndSubImageTest::TextureSubImage<1, false>(glw::GLenum target, glw::GLuint texture, glw::GLint level,
1967 glw::GLint internalformat, glw::GLsizei width,
1968 glw::GLsizei height, glw::GLsizei depth, glw::GLenum format,
1969 glw::GLenum type, const glw::GLvoid* data)
1972 (void)internalformat;
1975 /* Shortcut for GL functionality. */
1976 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1979 gl.texSubImage1D(target, level, 0, width, format, type, data);
1980 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexSubImage1D has failed");
1982 /* TextureStorage* (not TextureSubImage) is tested so here we only throw when error occurs. */
1986 /** @brief TextureSubImage* wrapper.
1988 * @tparam D Texture dimenisons.
1989 * @tparam I Select between legacy/DSA way.
1991 * @return true if suuceed (in legacy always or throw), false otherwise.
1994 bool StorageAndSubImageTest::TextureSubImage<2, false>(glw::GLenum target, glw::GLuint texture, glw::GLint level,
1995 glw::GLint internalformat, glw::GLsizei width,
1996 glw::GLsizei height, glw::GLsizei depth, glw::GLenum format,
1997 glw::GLenum type, const glw::GLvoid* data)
2000 (void)internalformat;
2002 /* Shortcut for GL functionality. */
2003 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2006 gl.texSubImage2D(target, level, 0, 0, width, height, format, type, data);
2007 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexSubImage2D has failed");
2009 /* TextureStorage* (not TextureSubImage) is tested so here we only throw when error occurs. */
2013 /** @brief TextureSubImage* wrapper.
2015 * @tparam D Texture dimenisons.
2016 * @tparam I Select between legacy/DSA way.
2018 * @return true if suuceed (in legacy always or throw), false otherwise.
2021 bool StorageAndSubImageTest::TextureSubImage<3, false>(glw::GLenum target, glw::GLuint texture, glw::GLint level,
2022 glw::GLint internalformat, glw::GLsizei width,
2023 glw::GLsizei height, glw::GLsizei depth, glw::GLenum format,
2024 glw::GLenum type, const glw::GLvoid* data)
2027 (void)internalformat;
2028 /* Shortcut for GL functionality. */
2029 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2032 gl.texSubImage3D(target, level, 0, 0, 0, width, height, depth, format, type, data);
2033 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexSubImage3D has failed");
2035 /* TextureStorage* (not TextureSubImage) is tested so here we only throw when error occurs. */
2039 /** @brief TextureSubImage* wrapper.
2041 * @tparam D Texture dimenisons.
2042 * @tparam I Select between legacy/DSA way.
2044 * @return true if suuceed (in legacy always or throw), false otherwise.
2047 bool StorageAndSubImageTest::TextureSubImage<1, true>(glw::GLenum target, glw::GLuint texture, glw::GLint level,
2048 glw::GLint internalformat, glw::GLsizei width,
2049 glw::GLsizei height, glw::GLsizei depth, glw::GLenum format,
2050 glw::GLenum type, const glw::GLvoid* data)
2053 (void)internalformat;
2056 /* Shortcut for GL functionality. */
2057 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2060 gl.textureSubImage1D(texture, level, 0, width, format, type, data);
2062 /* Error checking. */
2065 if (GL_NO_ERROR != (error = gl.getError()))
2068 m_context.getTestContext().getLog()
2069 << tcu::TestLog::Message << "glTextureSubImage1D unexpectedly generated error " << glu::getErrorStr(error)
2070 << " during test with level " << level << ", width " << width << ", format "
2071 << glu::getTextureFormatStr(format) << " and type " << glu::getTypeStr(type) << "."
2072 << tcu::TestLog::EndMessage;
2083 /** @brief TextureSubImage* wrapper.
2085 * @tparam D Texture dimenisons.
2086 * @tparam I Select between legacy/DSA way.
2088 * @return true if suuceed (in legacy always or throw), false otherwise.
2091 bool StorageAndSubImageTest::TextureSubImage<2, true>(glw::GLenum target, glw::GLuint texture, glw::GLint level,
2092 glw::GLint internalformat, glw::GLsizei width,
2093 glw::GLsizei height, glw::GLsizei depth, glw::GLenum format,
2094 glw::GLenum type, const glw::GLvoid* data)
2097 (void)internalformat;
2099 /* Shortcut for GL functionality. */
2100 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2103 gl.textureSubImage2D(texture, level, 0, 0, width, height, format, type, data);
2105 /* Error checking. */
2108 if (GL_NO_ERROR != (error = gl.getError()))
2111 m_context.getTestContext().getLog()
2112 << tcu::TestLog::Message << "glTextureSubImage2D unexpectedly generated error " << glu::getErrorStr(error)
2113 << " during test with level " << level << ", width " << width << ", height " << height << ", format "
2114 << glu::getTextureFormatStr(format) << " and type " << glu::getTypeStr(type) << "."
2115 << tcu::TestLog::EndMessage;
2126 /** @brief TextureSubImage* wrapper.
2128 * @tparam D Texture dimenisons.
2129 * @tparam I Select between legacy/DSA way.
2131 * @return true if suuceed (in legacy always or throw), false otherwise.
2134 bool StorageAndSubImageTest::TextureSubImage<3, true>(glw::GLenum target, glw::GLuint texture, glw::GLint level,
2135 glw::GLint internalformat, glw::GLsizei width,
2136 glw::GLsizei height, glw::GLsizei depth, glw::GLenum format,
2137 glw::GLenum type, const glw::GLvoid* data)
2140 (void)internalformat;
2141 /* Shortcut for GL functionality. */
2142 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2145 gl.textureSubImage3D(texture, level, 0, 0, 0, width, height, depth, format, type, data);
2147 /* Error checking. */
2150 if (GL_NO_ERROR != (error = gl.getError()))
2153 m_context.getTestContext().getLog()
2154 << tcu::TestLog::Message << "glTextureSubImage3D unexpectedly generated error " << glu::getErrorStr(error)
2155 << " during test with level " << level << ", width " << width << ", height " << height << ", depth "
2156 << depth << ", format " << glu::getTextureFormatStr(format) << " and type " << glu::getTypeStr(type) << "."
2157 << tcu::TestLog::EndMessage;
2168 /** @brief Create texture.
2171 * @tparam S Size (# of components).
2172 * @tparam N Is normalized.
2173 * @tparam D Dimmensions.
2174 * @tparam I Test SubImage or Storage.
2176 * @return True if succeded, false otherwise.
2178 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2179 bool StorageAndSubImageTest::CreateTexture()
2181 /* Shortcut for GL functionality. */
2182 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2184 /* Objects creation. */
2185 gl.genTextures(1, &m_to);
2186 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
2188 gl.bindTexture(TextureTarget<D>(), m_to);
2189 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
2191 /* Storage creation. */
2192 if (TextureStorage<D, I>(TextureTarget<D>(), m_to, 1, InternalFormat<T, S, N>(), TestReferenceDataWidth<D>(),
2193 TestReferenceDataHeight<D>(), TestReferenceDataDepth<D>()))
2196 if (TextureSubImage<D, I>(TextureTarget<D>(), m_to, 0, InternalFormat<T, S, N>(), TestReferenceDataWidth<D>(),
2197 TestReferenceDataHeight<D>(), TestReferenceDataDepth<D>(), Format<S, N>(), Type<T>(),
2198 ReferenceData<T, N>()))
2200 glTexParameteri(TextureTarget<D>(), GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2201 glTexParameteri(TextureTarget<D>(), GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2211 /** @brief Compre results with the reference.
2214 * @tparam S Size (# of components).
2215 * @tparam N Is normalized.
2217 * @return True if equal, false otherwise.
2219 template <typename T, glw::GLint S, bool N, glw::GLuint D>
2220 bool StorageAndSubImageTest::Check()
2222 /* Shortcut for GL functionality. */
2223 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2225 /* Fetching data. */
2226 std::vector<T> result(TestReferenceDataCount<S, D>());
2228 gl.pixelStorei(GL_UNPACK_ALIGNMENT, sizeof(T));
2229 GLU_EXPECT_NO_ERROR(gl.getError(), "glPixelStorei has failed");
2231 gl.pixelStorei(GL_PACK_ALIGNMENT, sizeof(T));
2232 GLU_EXPECT_NO_ERROR(gl.getError(), "glPixelStorei has failed");
2234 glw::GLuint fbo_size_x = 0;
2245 fbo_size_x = 2 * 3 * 4;
2251 gl.readnPixels(0, 0, fbo_size_x, 1, Format<S, N>(), Type<T>(), TestReferenceDataSize<T, S, D>(),
2252 (glw::GLvoid*)(&result[0]));
2253 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels has failed");
2256 for (glw::GLuint i = 0; i < TestReferenceDataCount<S, D>(); ++i)
2258 if (!Compare<T>(result[i], ReferenceData<T, N>()[i]))
2267 /** @brief Test case function.
2270 * @tparam S Size (# of components).
2271 * @tparam N Is normalized.
2272 * @tparam D Number of texture dimensions.
2274 * @return True if test succeeded, false otherwise.
2276 template <typename T, glw::GLint S, bool N, glw::GLuint D, bool I>
2277 bool StorageAndSubImageTest::Test()
2280 PrepareFramebuffer(InternalFormat<T, S, N>(), D);
2282 if (!CreateTexture<T, S, N, D, I>())
2290 /* Compare results with reference. */
2291 bool result = Check<T, S, N, D>();
2302 /** @brief Lopp test function over S.
2305 * @tparam N Is normalized.
2306 * @tparam D Texture dimension.
2307 * @tparam I Choose between SubImage and Storage tests.
2309 * @param [in] skip_rgb Skip test of S = 3 (needed for some formats).
2311 * @return True if tests succeeded, false otherwise.
2313 template <typename T, bool N, glw::GLuint D, bool I>
2314 bool StorageAndSubImageTest::LoopTestOverS(bool skip_rgb)
2316 /* Prepare one program per test loop. */
2317 PrepareProgram(FragmentShaderDeclaration<T, N, D>(), FragmentShaderTail<D>());
2322 result &= Test<T, 1, N, D, I>();
2324 result &= Test<T, 2, N, D, I>();
2328 result &= Test<T, 3, N, D, I>();
2331 result &= Test<T, 4, N, D, I>();
2341 /** @brief Lopp test function over D and over S.
2344 * @tparam N Is normalized.
2345 * @tparam I Choose between SubImage and Storage tests.
2347 * @param [in] skip_rgb Skip test of S = 3 (needed for some formats).
2349 * @return True if tests succeeded, false otherwise.
2351 template <typename T, bool N, bool I>
2352 bool StorageAndSubImageTest::LoopTestOverDOverS(bool skip_rgb)
2356 result &= LoopTestOverS<T, N, 1, I>(skip_rgb);
2357 result &= LoopTestOverS<T, N, 2, I>(skip_rgb);
2358 result &= LoopTestOverS<T, N, 3, I>(skip_rgb);
2363 /** @brief Function prepares framebuffer with internal format color attachment.
2364 * Viewport is set up. Content of the framebuffer is cleared.
2366 * @note The function may throw if unexpected error has occured.
2368 void StorageAndSubImageTest::PrepareFramebuffer(const glw::GLenum internal_format, const glw::GLuint D)
2370 /* Shortcut for GL functionality. */
2371 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2373 /* Prepare framebuffer. */
2374 gl.genFramebuffers(1, &m_fbo);
2375 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
2377 gl.genRenderbuffers(1, &m_rbo);
2378 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
2380 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
2381 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
2383 gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo);
2384 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
2386 glw::GLuint fbo_size_x = 0;
2397 fbo_size_x = 2 * 3 * 4;
2403 gl.renderbufferStorage(GL_RENDERBUFFER, internal_format, fbo_size_x, 1);
2404 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage call failed.");
2406 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo);
2407 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer call failed.");
2409 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
2414 gl.viewport(0, 0, fbo_size_x, 1);
2415 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
2417 /* Clear framebuffer's content. */
2418 gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
2419 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor call failed.");
2421 gl.clear(GL_COLOR_BUFFER_BIT);
2422 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear call failed.");
2425 /** @brief Prepare program
2427 * @param [in] variable_declaration Variables declaration part of fragment shader source code.
2428 * @param [in] tail Tail part of fragment shader source code.
2430 void StorageAndSubImageTest::PrepareProgram(const glw::GLchar* variable_declaration, const glw::GLchar* tail)
2432 /* Shortcut for GL functionality */
2433 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2437 glw::GLchar const* source[3];
2438 glw::GLsizei const count;
2439 glw::GLenum const type;
2441 } shader[] = { { { s_vertex_shader, NULL, NULL }, 1, GL_VERTEX_SHADER, 0 },
2442 { { s_fragment_shader_head, variable_declaration, tail }, 3, GL_FRAGMENT_SHADER, 0 } };
2444 glw::GLuint const shader_count = sizeof(shader) / sizeof(shader[0]);
2448 /* Create program. */
2449 m_po = gl.createProgram();
2450 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateProgram call failed.");
2452 /* Shader compilation. */
2454 for (glw::GLuint i = 0; i < shader_count; ++i)
2457 shader[i].id = gl.createShader(shader[i].type);
2459 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateShader call failed.");
2461 gl.attachShader(m_po, shader[i].id);
2463 GLU_EXPECT_NO_ERROR(gl.getError(), "glAttachShader call failed.");
2465 gl.shaderSource(shader[i].id, shader[i].count, shader[i].source, NULL);
2467 GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource call failed.");
2469 gl.compileShader(shader[i].id);
2471 GLU_EXPECT_NO_ERROR(gl.getError(), "glCompileShader call failed.");
2473 glw::GLint status = GL_FALSE;
2475 gl.getShaderiv(shader[i].id, GL_COMPILE_STATUS, &status);
2476 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv call failed.");
2478 if (GL_FALSE == status)
2480 glw::GLint log_size = 0;
2481 gl.getShaderiv(shader[i].id, GL_INFO_LOG_LENGTH, &log_size);
2482 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv call failed.");
2484 glw::GLchar* log_text = new glw::GLchar[log_size];
2486 gl.getShaderInfoLog(shader[i].id, log_size, NULL, &log_text[0]);
2488 m_context.getTestContext().getLog()
2489 << tcu::TestLog::Message << "Shader compilation has failed.\n"
2490 << "Shader type: " << glu::getShaderTypeStr(shader[i].type) << "\n"
2491 << "Shader compilation error log:\n"
2493 << "Shader source code:\n"
2494 << shader[i].source[0] << (shader[i].source[1] ? shader[i].source[1] : "")
2495 << (shader[i].source[2] ? shader[i].source[2] : "") << "\n"
2496 << tcu::TestLog::EndMessage;
2500 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderInfoLog call failed.");
2508 gl.linkProgram(m_po);
2510 GLU_EXPECT_NO_ERROR(gl.getError(), "glTransformFeedbackVaryings call failed.");
2512 glw::GLint status = GL_FALSE;
2514 gl.getProgramiv(m_po, GL_LINK_STATUS, &status);
2516 if (GL_TRUE == status)
2518 for (glw::GLuint i = 0; i < shader_count; ++i)
2522 gl.detachShader(m_po, shader[i].id);
2524 GLU_EXPECT_NO_ERROR(gl.getError(), "glDetachShader call failed.");
2530 glw::GLint log_size = 0;
2532 gl.getProgramiv(m_po, GL_INFO_LOG_LENGTH, &log_size);
2534 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramiv call failed.");
2536 glw::GLchar* log_text = new glw::GLchar[log_size];
2538 gl.getProgramInfoLog(m_po, log_size, NULL, &log_text[0]);
2540 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Program linkage has failed due to:\n"
2542 << tcu::TestLog::EndMessage;
2546 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramInfoLog call failed.");
2555 gl.deleteProgram(m_po);
2561 for (glw::GLuint i = 0; i < shader_count; ++i)
2563 if (0 != shader[i].id)
2565 gl.deleteShader(shader[i].id);
2577 /** @brief Prepare VAO.
2579 void StorageAndSubImageTest::PrepareVertexArray()
2581 /* Shortcut for GL functionality. */
2582 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2584 gl.genVertexArrays(1, &m_vao);
2585 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays has failed");
2587 gl.bindVertexArray(m_vao);
2588 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray has failed");
2591 /** @brief Test's draw call.
2593 void StorageAndSubImageTest::Draw()
2595 /* Shortcut for GL functionality. */
2596 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2598 gl.useProgram(m_po);
2599 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram has failed");
2601 gl.activeTexture(GL_TEXTURE0);
2602 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
2604 gl.bindTextureUnit(0, m_to);
2605 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
2607 gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
2608 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays has failed");
2611 /** @brief Clean GL objects, test variables and GL errors.
2613 void StorageAndSubImageTest::CleanTexture()
2615 /* Shortcut for GL functionality. */
2616 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2621 gl.deleteTextures(1, &m_to);
2627 /** @brief Clean GL objects, test variables and GL errors.
2629 void StorageAndSubImageTest::CleanFramebuffer()
2631 /* Shortcut for GL functionality. */
2632 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2637 gl.deleteFramebuffers(1, &m_fbo);
2645 gl.deleteRenderbuffers(1, &m_rbo);
2651 /** @brief Clean GL objects, test variables and GL errors.
2653 void StorageAndSubImageTest::CleanProgram()
2655 /* Shortcut for GL functionality. */
2656 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2663 gl.deleteProgram(m_po);
2669 /** @brief Clean GL objects, test variables and GL errors.
2671 void StorageAndSubImageTest::CleanErrors()
2673 /* Shortcut for GL functionality. */
2674 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2676 /* Query all errors until GL_NO_ERROR occure. */
2677 while (GL_NO_ERROR != gl.getError())
2681 /** @brief Clean GL objects, test variables and GL errors.
2683 void StorageAndSubImageTest::CleanVertexArray()
2685 /* Shortcut for GL functionality. */
2686 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2690 gl.bindVertexArray(0);
2692 gl.deleteVertexArrays(1, &m_vao);
2698 /** @brief Iterate Storage Test cases.
2700 * @return Iteration result.
2702 tcu::TestNode::IterateResult StorageAndSubImageTest::iterate()
2704 /* Shortcut for GL functionality. */
2705 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2707 /* Get context setup. */
2708 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
2709 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
2711 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
2713 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
2718 /* Running tests. */
2720 bool is_error = false;
2724 PrepareVertexArray();
2726 /* Test TextureStorage* */
2727 is_ok &= LoopTestOverDOverS<glw::GLbyte, false, false>(true);
2728 is_ok &= LoopTestOverDOverS<glw::GLubyte, false, false>(true);
2729 is_ok &= LoopTestOverDOverS<glw::GLshort, false, false>(true);
2730 is_ok &= LoopTestOverDOverS<glw::GLushort, false, false>(true);
2731 is_ok &= LoopTestOverDOverS<glw::GLint, false, false>(false);
2732 is_ok &= LoopTestOverDOverS<glw::GLuint, false, false>(false);
2733 is_ok &= LoopTestOverDOverS<glw::GLubyte, true, false>(true);
2734 is_ok &= LoopTestOverDOverS<glw::GLushort, true, false>(true);
2735 is_ok &= LoopTestOverDOverS<glw::GLfloat, true, false>(false);
2737 /* Test TextureSubImage* */
2738 is_ok &= LoopTestOverDOverS<glw::GLbyte, false, true>(true);
2739 is_ok &= LoopTestOverDOverS<glw::GLubyte, false, true>(true);
2740 is_ok &= LoopTestOverDOverS<glw::GLshort, false, true>(true);
2741 is_ok &= LoopTestOverDOverS<glw::GLushort, false, true>(true);
2742 is_ok &= LoopTestOverDOverS<glw::GLint, false, true>(false);
2743 is_ok &= LoopTestOverDOverS<glw::GLuint, false, true>(false);
2744 is_ok &= LoopTestOverDOverS<glw::GLubyte, true, true>(true);
2745 is_ok &= LoopTestOverDOverS<glw::GLushort, true, true>(true);
2746 is_ok &= LoopTestOverDOverS<glw::GLfloat, true, true>(false);
2761 /* Errors clean up. */
2762 while (gl.getError())
2765 /* Result's setup. */
2768 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
2774 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
2778 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
2785 /* Vertex shader source code. */
2786 const glw::GLchar* StorageAndSubImageTest::s_vertex_shader = "#version 450\n"
2790 " switch(gl_VertexID)\n"
2793 " gl_Position = vec4(-1.0, 1.0, 0.0, 1.0);\n"
2796 " gl_Position = vec4( 1.0, 1.0, 0.0, 1.0);\n"
2799 " gl_Position = vec4(-1.0,-1.0, 0.0, 1.0);\n"
2802 " gl_Position = vec4( 1.0,-1.0, 0.0, 1.0);\n"
2807 /* Fragment shader source program. */
2808 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_head =
2811 "layout(pixel_center_integer) in vec4 gl_FragCoord;\n"
2814 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_1D_fdecl_lowp =
2815 "uniform sampler1D texture_input;\nout vec4 texture_output;\n";
2816 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_1D_idecl_lowp =
2817 "uniform isampler1D texture_input;\nout ivec4 texture_output;\n";
2818 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_1D_udecl_lowp =
2819 "uniform usampler1D texture_input;\nout uvec4 texture_output;\n";
2820 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_1D_fdecl_mediump =
2821 "uniform sampler1D texture_input;\nout vec4 texture_output;\n";
2822 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_1D_idecl_mediump =
2823 "uniform isampler1D texture_input;\nout ivec4 texture_output;\n";
2824 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_1D_udecl_mediump =
2825 "uniform usampler1D texture_input;\nout uvec4 texture_output;\n";
2826 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_1D_fdecl_highp =
2827 "uniform sampler1D texture_input;\nout vec4 texture_output;\n";
2828 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_1D_idecl_highp =
2829 "uniform isampler1D texture_input;\nout ivec4 texture_output;\n";
2830 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_1D_udecl_highp =
2831 "uniform usampler1D texture_input;\nout uvec4 texture_output;\n";
2833 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_2D_fdecl_lowp =
2834 "uniform sampler2D texture_input;\nout vec4 texture_output;\n";
2835 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_2D_idecl_lowp =
2836 "uniform isampler2D texture_input;\nout ivec4 texture_output;\n";
2837 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_2D_udecl_lowp =
2838 "uniform usampler2D texture_input;\nout uvec4 texture_output;\n";
2839 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_2D_fdecl_mediump =
2840 "uniform sampler2D texture_input;\nout vec4 texture_output;\n";
2841 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_2D_idecl_mediump =
2842 "uniform isampler2D texture_input;\nout ivec4 texture_output;\n";
2843 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_2D_udecl_mediump =
2844 "uniform usampler2D texture_input;\nout uvec4 texture_output;\n";
2845 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_2D_fdecl_highp =
2846 "uniform sampler2D texture_input;\nout vec4 texture_output;\n";
2847 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_2D_idecl_highp =
2848 "uniform isampler2D texture_input;\nout ivec4 texture_output;\n";
2849 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_2D_udecl_highp =
2850 "uniform usampler2D texture_input;\nout uvec4 texture_output;\n";
2852 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_3D_fdecl_lowp =
2853 "uniform sampler3D texture_input;\nout vec4 texture_output;\n";
2854 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_3D_idecl_lowp =
2855 "uniform isampler3D texture_input;\nout ivec4 texture_output;\n";
2856 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_3D_udecl_lowp =
2857 "uniform usampler3D texture_input;\nout uvec4 texture_output;\n";
2858 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_3D_fdecl_mediump =
2859 "uniform sampler3D texture_input;\nout vec4 texture_output;\n";
2860 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_3D_idecl_mediump =
2861 "uniform isampler3D texture_input;\nout ivec4 texture_output;\n";
2862 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_3D_udecl_mediump =
2863 "uniform usampler3D texture_input;\nout uvec4 texture_output;\n";
2864 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_3D_fdecl_highp =
2865 "uniform sampler3D texture_input;\nout vec4 texture_output;\n";
2866 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_3D_idecl_highp =
2867 "uniform isampler3D texture_input;\nout ivec4 texture_output;\n";
2868 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_3D_udecl_highp =
2869 "uniform usampler3D texture_input;\nout uvec4 texture_output;\n";
2871 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_1D_tail =
2875 " texture_output = texelFetch(texture_input, int(gl_FragCoord.x), 0);\n"
2878 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_2D_tail =
2882 " texture_output = texelFetch(texture_input, ivec2(int(gl_FragCoord.x) % 2, int(floor(gl_FragCoord.x / 2))), "
2886 const glw::GLchar* StorageAndSubImageTest::s_fragment_shader_3D_tail =
2890 " texture_output = texelFetch(texture_input, ivec3(int(gl_FragCoord.x) % 2, int(floor(gl_FragCoord.x / 2)) % 3, "
2891 "int(floor(gl_FragCoord.x / 2 / 3))), 0);\n"
2894 /******************************** Storage Multisample Test Implementation ********************************/
2896 /** @brief Storage Multisample Test constructor.
2898 * @param [in] context OpenGL context.
2900 StorageMultisampleTest::StorageMultisampleTest(deqp::Context& context)
2901 : deqp::TestCase(context, "textures_storage_multisample", "Texture Storage Multisample Test")
2911 /* Intentionally left blank. */
2914 /** @brief Count of reference data to be teted.
2916 * @tparam S Size (# of components).
2917 * @tparam D Texture dimenisons.
2921 template <glw::GLint S, glw::GLuint D>
2922 glw::GLuint StorageMultisampleTest::TestReferenceDataCount()
2924 return 2 /* 1D */ * ((D > 1) ? 3 : 1) /* 2D */ * ((D > 2) ? 4 : 1) /* 3D */ * S /* components */;
2927 /** @brief Size of reference data to be teted.
2930 * @tparam S Size (# of components).
2931 * @tparam D Texture dimenisons.
2935 template <typename T, glw::GLint S, glw::GLuint D>
2936 glw::GLuint StorageMultisampleTest::TestReferenceDataSize()
2938 return TestReferenceDataCount<S, D>() * sizeof(T);
2941 /** @brief Height, width or depth of reference data to be teted.
2943 * @tparam D Texture dimenisons.
2945 * @return Height, width or depth.
2948 glw::GLuint StorageMultisampleTest::TestReferenceDataHeight<2>()
2954 glw::GLuint StorageMultisampleTest::TestReferenceDataHeight<3>()
2956 return TestReferenceDataHeight<2>();
2960 glw::GLuint StorageMultisampleTest::TestReferenceDataDepth<2>()
2966 glw::GLuint StorageMultisampleTest::TestReferenceDataDepth<3>()
2971 template <glw::GLuint D>
2972 glw::GLuint StorageMultisampleTest::TestReferenceDataWidth()
2977 /** @brief Fragment shader declaration selector.
2980 * @tparam N Normalized flag.
2981 * @tparam D Texture dimenisons.
2983 * @return Frgment shader source code part.
2986 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLubyte, true, 2>()
2988 return s_fragment_shader_ms_2D_fdecl_lowp;
2992 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLbyte, false, 2>()
2994 return s_fragment_shader_ms_2D_idecl_lowp;
2998 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLubyte, false, 2>()
3000 return s_fragment_shader_ms_2D_udecl_lowp;
3004 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLushort, true, 2>()
3006 return s_fragment_shader_ms_2D_fdecl_mediump;
3010 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLshort, false, 2>()
3012 return s_fragment_shader_ms_2D_idecl_mediump;
3016 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLushort, false, 2>()
3018 return s_fragment_shader_ms_2D_udecl_mediump;
3022 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLfloat, true, 2>()
3024 return s_fragment_shader_ms_2D_fdecl_highp;
3028 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLint, false, 2>()
3030 return s_fragment_shader_ms_2D_idecl_highp;
3034 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLuint, false, 2>()
3036 return s_fragment_shader_ms_2D_udecl_highp;
3039 /** @brief Fragment shader declaration selector.
3042 * @tparam N Normalized flag.
3043 * @tparam D Texture dimenisons.
3045 * @return Frgment shader source code part.
3048 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLubyte, true, 3>()
3050 return s_fragment_shader_ms_3D_fdecl_lowp;
3054 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLbyte, false, 3>()
3056 return s_fragment_shader_ms_3D_idecl_lowp;
3060 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLubyte, false, 3>()
3062 return s_fragment_shader_ms_3D_udecl_lowp;
3066 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLushort, true, 3>()
3068 return s_fragment_shader_ms_3D_fdecl_mediump;
3072 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLshort, false, 3>()
3074 return s_fragment_shader_ms_3D_idecl_mediump;
3078 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLushort, false, 3>()
3080 return s_fragment_shader_ms_3D_udecl_mediump;
3084 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLfloat, true, 3>()
3086 return s_fragment_shader_ms_3D_fdecl_highp;
3090 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLint, false, 3>()
3092 return s_fragment_shader_ms_3D_idecl_highp;
3096 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationMultisample<glw::GLuint, false, 3>()
3098 return s_fragment_shader_ms_3D_udecl_highp;
3101 /** @brief Fragment shader declaration selector.
3104 * @tparam N Normalized flag.
3105 * @tparam D Texture dimenisons.
3107 * @return Frgment shader source code part.
3110 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLubyte, true, 2>()
3112 return s_fragment_shader_aux_2D_fdecl_lowp;
3116 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLbyte, false, 2>()
3118 return s_fragment_shader_aux_2D_idecl_lowp;
3122 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLubyte, false, 2>()
3124 return s_fragment_shader_aux_2D_udecl_lowp;
3128 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLushort, true, 2>()
3130 return s_fragment_shader_aux_2D_fdecl_mediump;
3134 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLshort, false, 2>()
3136 return s_fragment_shader_aux_2D_idecl_mediump;
3140 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLushort, false, 2>()
3142 return s_fragment_shader_aux_2D_udecl_mediump;
3146 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLfloat, true, 2>()
3148 return s_fragment_shader_aux_2D_fdecl_highp;
3152 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLint, false, 2>()
3154 return s_fragment_shader_aux_2D_idecl_highp;
3158 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLuint, false, 2>()
3160 return s_fragment_shader_aux_2D_udecl_highp;
3163 /** @brief Fragment shader declaration selector.
3166 * @tparam N Normalized flag.
3167 * @tparam D Texture dimenisons.
3169 * @return Frgment shader source code part.
3172 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLubyte, true, 3>()
3174 return s_fragment_shader_aux_3D_fdecl_lowp;
3178 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLbyte, false, 3>()
3180 return s_fragment_shader_aux_3D_idecl_lowp;
3184 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLubyte, false, 3>()
3186 return s_fragment_shader_aux_3D_udecl_lowp;
3190 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLushort, true, 3>()
3192 return s_fragment_shader_aux_3D_fdecl_mediump;
3196 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLshort, false, 3>()
3198 return s_fragment_shader_aux_3D_idecl_mediump;
3202 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLushort, false, 3>()
3204 return s_fragment_shader_aux_3D_udecl_mediump;
3208 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLfloat, true, 3>()
3210 return s_fragment_shader_aux_3D_fdecl_highp;
3214 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLint, false, 3>()
3216 return s_fragment_shader_aux_3D_idecl_highp;
3220 const glw::GLchar* StorageMultisampleTest::FragmentShaderDeclarationAuxiliary<glw::GLuint, false, 3>()
3222 return s_fragment_shader_aux_3D_udecl_highp;
3225 /** @brief Fragment shader tail selector.
3227 * @tparam D Texture dimenisons.
3229 * @return Frgment shader source code part.
3232 const glw::GLchar* StorageMultisampleTest::FragmentShaderTail<2>()
3234 return s_fragment_shader_tail_2D;
3238 const glw::GLchar* StorageMultisampleTest::FragmentShaderTail<3>()
3240 return s_fragment_shader_tail_3D;
3243 /** @brief Texture target selector.
3245 * @tparam D Texture dimenisons.
3247 * @return Texture target.
3250 glw::GLenum StorageMultisampleTest::InputTextureTarget<2>()
3252 return GL_TEXTURE_2D;
3256 glw::GLenum StorageMultisampleTest::InputTextureTarget<3>()
3258 return GL_TEXTURE_2D_ARRAY;
3261 /** @brief Prepare texture data for input texture.
3263 * @tparam D Texture dimenisons.
3265 * @note parameters as passed to texImage*
3268 void StorageMultisampleTest::InputTextureImage<2>(const glw::GLenum internal_format, const glw::GLuint width,
3269 const glw::GLuint height, const glw::GLuint depth,
3270 const glw::GLenum format, const glw::GLenum type,
3271 const glw::GLvoid* data)
3274 /* Shortcut for GL functionality. */
3275 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3278 gl.texImage2D(InputTextureTarget<2>(), 0, internal_format, width, height, 0, format, type, data);
3279 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
3282 /** @brief Prepare texture data for input texture.
3284 * @tparam D Texture dimenisons.
3286 * @note parameters as passed to texImage*
3289 void StorageMultisampleTest::InputTextureImage<3>(const glw::GLenum internal_format, const glw::GLuint width,
3290 const glw::GLuint height, const glw::GLuint depth,
3291 const glw::GLenum format, const glw::GLenum type,
3292 const glw::GLvoid* data)
3294 /* Shortcut for GL functionality. */
3295 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3298 gl.texImage3D(InputTextureTarget<3>(), 0, internal_format, width, height, depth, 0, format, type, data);
3299 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
3302 /** @brief Create texture.
3305 * @tparam S Size (# of components).
3306 * @tparam N Is normalized.
3307 * @tparam D Dimmensions.
3309 template <typename T, glw::GLint S, bool N, glw::GLuint D>
3310 void StorageMultisampleTest::CreateInputTexture()
3312 /* Shortcut for GL functionality. */
3313 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3315 /* Objects creation. */
3316 gl.genTextures(1, &m_to);
3317 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
3319 gl.bindTexture(InputTextureTarget<D>(), m_to);
3320 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
3323 InputTextureImage<D>(InternalFormat<T, S, N>(), TestReferenceDataWidth<D>(), TestReferenceDataHeight<D>(),
3324 TestReferenceDataDepth<D>(), Format<S, N>(), Type<T>(), ReferenceData<T, N>());
3326 /* Parameter setup. */
3327 gl.texParameteri(InputTextureTarget<D>(), GL_TEXTURE_MAG_FILTER, GL_NEAREST);
3328 gl.texParameteri(InputTextureTarget<D>(), GL_TEXTURE_MIN_FILTER, GL_NEAREST);
3329 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri call failed.");
3332 /** @brief Compre results with the reference.
3335 * @tparam S Size (# of components).
3336 * @tparam N Is normalized.
3338 * @return True if equal, false otherwise.
3340 template <typename T, glw::GLint S, bool N, glw::GLuint D>
3341 bool StorageMultisampleTest::Check()
3343 /* Shortcut for GL functionality. */
3344 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3346 /* Fetching data fro auxiliary texture. */
3347 std::vector<T> result(TestReferenceDataCount<S, D>());
3349 gl.bindTexture(InputTextureTarget<D>() /* Auxiliary target is the same as input. */, m_to_aux);
3350 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
3352 gl.getTexImage(InputTextureTarget<D>() /* Auxiliary target is the same as input. */, 0, Format<S, N>(), Type<T>(),
3353 (glw::GLvoid*)(&result[0]));
3354 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexImage has failed");
3357 for (glw::GLuint i = 0; i < TestReferenceDataCount<S, D>(); ++i)
3359 if (!Compare<T>(result[i], ReferenceData<T, N>()[i]))
3368 /** @brief Test case function.
3371 * @tparam S Size (# of components).
3372 * @tparam N Is normalized.
3373 * @tparam D Number of texture dimensions.
3375 * @return True if test succeeded, false otherwise.
3377 template <typename T, glw::GLint S, bool N, glw::GLuint D>
3378 bool StorageMultisampleTest::Test()
3380 /* Shortcut for GL functionality. */
3381 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3384 gl.pixelStorei(GL_UNPACK_ALIGNMENT, sizeof(T));
3385 GLU_EXPECT_NO_ERROR(gl.getError(), "glPixelStorei has failed");
3387 gl.pixelStorei(GL_PACK_ALIGNMENT, sizeof(T));
3388 GLU_EXPECT_NO_ERROR(gl.getError(), "glPixelStorei has failed");
3390 CreateInputTexture<T, S, N, D>();
3392 if (!PrepareFramebufferMultisample<D>(InternalFormat<T, S, N>()))
3394 CleanInputTexture();
3399 PrepareFramebufferAuxiliary<D>(InternalFormat<T, S, N>());
3404 /* Compare results with reference. */
3405 bool result = Check<T, S, N, D>();
3408 CleanAuxiliaryTexture();
3409 CleanFramebuffers();
3410 CleanInputTexture();
3417 /** @brief Lopp test function over S.
3420 * @tparam N Is normalized.
3421 * @tparam D Texture dimension.
3423 * @param [in] skip_rgb Skip test of S = 3 (needed for some formats).
3425 * @return True if tests succeeded, false otherwise.
3427 template <typename T, bool N, glw::GLuint D>
3428 bool StorageMultisampleTest::LoopTestOverS(bool skip_rgb)
3430 /* Prepare one program to create multisample texture and one to copy it to regular texture. */
3431 m_po_ms = PrepareProgram(FragmentShaderDeclarationMultisample<T, N, D>(), FragmentShaderTail<D>());
3432 m_po_aux = PrepareProgram(FragmentShaderDeclarationAuxiliary<T, N, D>(), FragmentShaderTail<D>());
3437 result &= Test<T, 1, N, D>();
3439 result &= Test<T, 2, N, D>();
3443 result &= Test<T, 3, N, D>();
3446 result &= Test<T, 4, N, D>();
3456 /** @brief Lopp test function over D and next over S.
3459 * @tparam N Is normalized.
3461 * @param [in] skip_rgb Skip test of S = 3 (needed for some formats).
3463 * @return True if tests succeeded, false otherwise.
3465 template <typename T, bool N>
3466 bool StorageMultisampleTest::LoopTestOverDOverS(bool skip_rgb)
3470 result &= LoopTestOverS<T, N, 2>(skip_rgb);
3471 result &= LoopTestOverS<T, N, 3>(skip_rgb);
3476 /** @brief Function prepares framebuffer with internal format color attachment.
3477 * Viewport is set up. Content of the framebuffer is cleared.
3479 * @note The function may throw if unexpected error has occured.
3482 bool StorageMultisampleTest::PrepareFramebufferMultisample<2>(const glw::GLenum internal_format)
3484 /* Shortcut for GL functionality. */
3485 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3487 /* Prepare framebuffer. */
3488 gl.genFramebuffers(1, &m_fbo_ms);
3489 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
3491 gl.genTextures(1, &m_to_ms);
3492 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
3494 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_ms);
3495 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
3497 gl.bindTexture(GL_TEXTURE_2D_MULTISAMPLE, m_to_ms);
3498 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
3500 gl.textureStorage2DMultisample(m_to_ms, 1, internal_format, TestReferenceDataWidth<2>(),
3501 TestReferenceDataHeight<2>(), false);
3505 if (GL_NO_ERROR != (error = gl.getError()))
3507 CleanFramebuffers();
3509 m_context.getTestContext().getLog()
3510 << tcu::TestLog::Message << "glTextureStorage2DMultisample unexpectedly generated error "
3511 << glu::getErrorStr(error) << " during the test of internal format "
3512 << glu::getTextureFormatStr(internal_format) << ". Test fails." << tcu::TestLog::EndMessage;
3517 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, m_to_ms, 0);
3518 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer call failed.");
3520 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
3525 gl.viewport(0, 0, TestReferenceDataWidth<2>(), TestReferenceDataHeight<2>());
3526 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
3528 /* Clear framebuffer's content. */
3529 gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
3530 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor call failed.");
3532 gl.clear(GL_COLOR_BUFFER_BIT);
3533 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear call failed.");
3538 /** @brief Function prepares framebuffer with internal format color attachment.
3539 * Viewport is set up. Content of the framebuffer is cleared.
3541 * @note The function may throw if unexpected error has occured.
3544 bool StorageMultisampleTest::PrepareFramebufferMultisample<3>(const glw::GLenum internal_format)
3546 /* Shortcut for GL functionality. */
3547 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3549 /* Prepare framebuffer. */
3550 gl.genFramebuffers(1, &m_fbo_ms);
3551 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
3553 gl.genTextures(1, &m_to_ms);
3554 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
3556 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_ms);
3557 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
3559 gl.bindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, m_to_ms);
3560 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
3562 gl.textureStorage3DMultisample(m_to_ms, 1, internal_format, TestReferenceDataWidth<3>(),
3563 TestReferenceDataHeight<3>(), TestReferenceDataDepth<3>(), false);
3567 if (GL_NO_ERROR != (error = gl.getError()))
3569 CleanFramebuffers();
3571 m_context.getTestContext().getLog()
3572 << tcu::TestLog::Message << "glTextureStorage3DMultisample unexpectedly generated error "
3573 << glu::getErrorStr(error) << " during the test of internal format "
3574 << glu::getTextureFormatStr(internal_format) << ". Test fails." << tcu::TestLog::EndMessage;
3579 for (glw::GLuint i = 0; i < TestReferenceDataDepth<3>(); ++i)
3581 gl.framebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, m_to_ms, 0, i);
3582 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer call failed.");
3585 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
3590 gl.viewport(0, 0, TestReferenceDataWidth<3>(), TestReferenceDataHeight<3>());
3591 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
3593 /* Clear framebuffer's content. */
3594 gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
3595 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor call failed.");
3597 gl.clear(GL_COLOR_BUFFER_BIT);
3598 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear call failed.");
3603 /** @brief Function prepares framebuffer with internal format color attachment.
3604 * Viewport is set up. Content of the framebuffer is cleared.
3606 * @note The function may throw if unexpected error has occured.
3609 void StorageMultisampleTest::PrepareFramebufferAuxiliary<2>(const glw::GLenum internal_format)
3611 /* Shortcut for GL functionality. */
3612 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3614 /* Prepare framebuffer. */
3615 gl.genFramebuffers(1, &m_fbo_aux);
3616 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
3618 gl.genTextures(1, &m_to_aux);
3619 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
3621 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_aux);
3622 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
3624 gl.bindTexture(GL_TEXTURE_2D, m_to_aux);
3625 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
3627 gl.textureStorage2D(m_to_aux, 1, internal_format, TestReferenceDataWidth<2>(), TestReferenceDataHeight<2>());
3628 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage2D call failed.");
3630 /* Parameter setup. */
3631 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
3632 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
3633 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri call failed.");
3635 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_to_aux, 0);
3636 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer call failed.");
3638 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
3643 gl.viewport(0, 0, TestReferenceDataWidth<2>(), TestReferenceDataHeight<2>());
3644 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
3646 /* Clear framebuffer's content. */
3647 gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
3648 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor call failed.");
3650 gl.clear(GL_COLOR_BUFFER_BIT);
3651 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear call failed.");
3654 /** @brief Function prepares framebuffer with internal format color attachment.
3655 * Viewport is set up. Content of the framebuffer is cleared.
3657 * @note The function may throw if unexpected error has occured.
3660 void StorageMultisampleTest::PrepareFramebufferAuxiliary<3>(const glw::GLenum internal_format)
3662 /* Shortcut for GL functionality. */
3663 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3665 /* Prepare framebuffer. */
3666 gl.genFramebuffers(1, &m_fbo_aux);
3667 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
3669 gl.genTextures(1, &m_to_aux);
3670 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
3672 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_aux);
3673 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
3675 gl.bindTexture(GL_TEXTURE_2D_ARRAY, m_to_aux);
3676 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
3678 gl.textureStorage3D(m_to_aux, 1, internal_format, TestReferenceDataWidth<3>(), TestReferenceDataHeight<3>(),
3679 TestReferenceDataDepth<3>());
3680 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage3D call failed.");
3682 /* Parameter setup. */
3683 gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
3684 gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
3685 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri call failed.");
3687 for (glw::GLuint i = 0; i < TestReferenceDataDepth<3>(); ++i)
3689 gl.framebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, m_to_aux, 0, i);
3690 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer call failed.");
3693 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
3698 gl.viewport(0, 0, TestReferenceDataWidth<3>(), TestReferenceDataHeight<3>());
3699 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
3701 /* Clear framebuffer's content. */
3702 gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
3703 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor call failed.");
3705 gl.clear(GL_COLOR_BUFFER_BIT);
3706 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear call failed.");
3709 /** @brief Prepare program
3711 * @param [in] variable_declaration Variables declaration part of fragment shader source code.
3712 * @param [in] tail Tail part of fragment shader source code.
3714 glw::GLuint StorageMultisampleTest::PrepareProgram(const glw::GLchar* variable_declaration, const glw::GLchar* tail)
3716 /* Shortcut for GL functionality */
3717 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3721 glw::GLchar const* source[3];
3722 glw::GLsizei const count;
3723 glw::GLenum const type;
3725 } shader[] = { { { s_vertex_shader, NULL, NULL }, 1, GL_VERTEX_SHADER, 0 },
3726 { { s_fragment_shader_head, variable_declaration, tail }, 3, GL_FRAGMENT_SHADER, 0 } };
3728 glw::GLuint const shader_count = sizeof(shader) / sizeof(shader[0]);
3734 /* Create program. */
3735 po = gl.createProgram();
3736 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateProgram call failed.");
3738 /* Shader compilation. */
3740 for (glw::GLuint i = 0; i < shader_count; ++i)
3743 shader[i].id = gl.createShader(shader[i].type);
3745 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateShader call failed.");
3747 gl.attachShader(po, shader[i].id);
3749 GLU_EXPECT_NO_ERROR(gl.getError(), "glAttachShader call failed.");
3751 gl.shaderSource(shader[i].id, shader[i].count, shader[i].source, NULL);
3753 GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource call failed.");
3755 gl.compileShader(shader[i].id);
3757 GLU_EXPECT_NO_ERROR(gl.getError(), "glCompileShader call failed.");
3759 glw::GLint status = GL_FALSE;
3761 gl.getShaderiv(shader[i].id, GL_COMPILE_STATUS, &status);
3762 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv call failed.");
3764 if (GL_FALSE == status)
3766 glw::GLint log_size = 0;
3767 gl.getShaderiv(shader[i].id, GL_INFO_LOG_LENGTH, &log_size);
3768 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv call failed.");
3770 glw::GLchar* log_text = new glw::GLchar[log_size];
3772 gl.getShaderInfoLog(shader[i].id, log_size, NULL, &log_text[0]);
3774 m_context.getTestContext().getLog()
3775 << tcu::TestLog::Message << "Shader compilation has failed.\n"
3776 << "Shader type: " << glu::getShaderTypeStr(shader[i].type) << "\n"
3777 << "Shader compilation error log:\n"
3779 << "Shader source code:\n"
3780 << shader[i].source[0] << (shader[i].source[1] ? shader[i].source[1] : "")
3781 << (shader[i].source[2] ? shader[i].source[2] : "") << "\n"
3782 << tcu::TestLog::EndMessage;
3786 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderInfoLog call failed.");
3796 GLU_EXPECT_NO_ERROR(gl.getError(), "glTransformFeedbackVaryings call failed.");
3798 glw::GLint status = GL_FALSE;
3800 gl.getProgramiv(po, GL_LINK_STATUS, &status);
3802 if (GL_TRUE == status)
3804 for (glw::GLuint i = 0; i < shader_count; ++i)
3808 gl.detachShader(po, shader[i].id);
3810 GLU_EXPECT_NO_ERROR(gl.getError(), "glDetachShader call failed.");
3816 glw::GLint log_size = 0;
3818 gl.getProgramiv(po, GL_INFO_LOG_LENGTH, &log_size);
3820 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramiv call failed.");
3822 glw::GLchar* log_text = new glw::GLchar[log_size];
3824 gl.getProgramInfoLog(po, log_size, NULL, &log_text[0]);
3826 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Program linkage has failed due to:\n"
3828 << tcu::TestLog::EndMessage;
3832 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramInfoLog call failed.");
3841 gl.deleteProgram(po);
3847 for (glw::GLuint i = 0; i < shader_count; ++i)
3849 if (0 != shader[i].id)
3851 gl.deleteShader(shader[i].id);
3865 /** @brief Prepare VAO.
3867 void StorageMultisampleTest::PrepareVertexArray()
3869 /* Shortcut for GL functionality. */
3870 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3872 gl.genVertexArrays(1, &m_vao);
3873 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays has failed");
3875 gl.bindVertexArray(m_vao);
3876 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray has failed");
3879 /** @brief Draw call 2D.
3882 void StorageMultisampleTest::Draw<2>()
3884 /* Shortcut for GL functionality. */
3885 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3887 /* Prepare multisample texture using draw call. */
3889 /* Prepare framebuffer with multisample texture. */
3890 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_ms);
3891 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
3893 /* Use first program program. */
3894 gl.useProgram(m_po_ms);
3895 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram has failed");
3897 /* Prepare texture to be drawn with. */
3898 gl.activeTexture(GL_TEXTURE0);
3899 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
3901 gl.bindTexture(GL_TEXTURE_2D, m_to);
3902 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
3904 gl.uniform1i(gl.getUniformLocation(m_po_ms, "texture_input"), 0);
3905 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i or glGetUniformLocation has failed");
3908 gl.drawBuffer(GL_COLOR_ATTACHMENT0);
3909 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawBuffer has failed");
3912 gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
3913 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays has failed");
3915 /* Copy multisample texture to auxiliary texture using draw call. */
3917 /* Prepare framebuffer with auxiliary texture. */
3918 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_aux);
3919 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
3921 /* Use first program program. */
3922 gl.useProgram(m_po_aux);
3923 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram has failed");
3925 /* Prepare texture to be drawn with. */
3926 gl.activeTexture(GL_TEXTURE0);
3927 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
3929 gl.bindTexture(GL_TEXTURE_2D_MULTISAMPLE, m_to_ms);
3930 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
3932 gl.bindTextureUnit(0, m_to);
3934 gl.uniform1i(gl.getUniformLocation(m_po_aux, "texture_input"), 0);
3935 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i or glGetUniformLocation has failed");
3938 gl.drawBuffer(GL_COLOR_ATTACHMENT0);
3939 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawBuffer has failed");
3942 gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
3943 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays has failed");
3946 /** @brief Draw call 3D.
3949 void StorageMultisampleTest::Draw<3>()
3951 /* Shortcut for GL functionality. */
3952 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3954 /* Prepare multisample texture using draw call. */
3956 /* Prepare framebuffer with multisample texture. */
3957 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_ms);
3958 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
3960 /* Use first program program. */
3961 gl.useProgram(m_po_ms);
3962 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram has failed");
3964 /* Prepare texture to be drawn with. */
3965 gl.activeTexture(GL_TEXTURE0);
3966 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
3968 gl.bindTexture(GL_TEXTURE_2D_ARRAY, m_to);
3969 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
3971 gl.uniform1i(gl.getUniformLocation(m_po_ms, "texture_input"), 0);
3972 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i or glGetUniformLocation has failed");
3974 /* For each texture layer. */
3975 for (glw::GLuint i = 0; i < TestReferenceDataDepth<3>(); ++i)
3978 gl.drawBuffer(GL_COLOR_ATTACHMENT0 + i);
3979 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawBuffer has failed");
3981 gl.uniform1i(gl.getUniformLocation(m_po_aux, "texture_layer"), i);
3982 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i or glGetUniformLocation has failed");
3985 gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
3986 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays has failed");
3989 /* Copy multisample texture to auxiliary texture using draw call. */
3991 /* Prepare framebuffer with auxiliary texture. */
3992 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_aux);
3993 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
3995 /* Use first program program. */
3996 gl.useProgram(m_po_aux);
3997 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram has failed");
3999 /* Prepare texture to be drawn with. */
4000 gl.activeTexture(GL_TEXTURE0);
4001 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
4003 gl.bindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, m_to_ms);
4004 GLU_EXPECT_NO_ERROR(gl.getError(), "glActiveTexture has failed");
4006 gl.bindTextureUnit(0, m_to);
4008 gl.uniform1i(gl.getUniformLocation(m_po_aux, "texture_input"), 0);
4009 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i or glGetUniformLocation has failed");
4011 /* For each texture layer. */
4012 for (glw::GLuint i = 0; i < TestReferenceDataDepth<3>(); ++i)
4015 gl.drawBuffer(GL_COLOR_ATTACHMENT0 + i);
4016 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawBuffer has failed");
4018 gl.uniform1i(gl.getUniformLocation(m_po_aux, "texture_layer"), i);
4019 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i or glGetUniformLocation has failed");
4022 gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
4023 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays has failed");
4027 /** @brief Clean GL objects, test variables and GL errors.
4029 void StorageMultisampleTest::CleanInputTexture()
4031 /* Shortcut for GL functionality. */
4032 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4037 gl.deleteTextures(1, &m_to);
4043 /** @brief Clean GL objects, test variables and GL errors.
4045 void StorageMultisampleTest::CleanAuxiliaryTexture()
4047 /* Shortcut for GL functionality. */
4048 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4052 gl.deleteTextures(1, &m_to_aux);
4058 /** @brief Clean GL objects, test variables and GL errors.
4060 void StorageMultisampleTest::CleanFramebuffers()
4062 /* Shortcut for GL functionality. */
4063 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4065 /* Mulitsample framebuffer. */
4068 gl.deleteFramebuffers(1, &m_fbo_ms);
4073 /* Mulitsample texture. */
4076 gl.deleteTextures(1, &m_to_ms);
4081 /* Auxiliary framebuffer. */
4084 gl.deleteFramebuffers(1, &m_fbo_aux);
4089 /* Auxiliary texture. */
4092 gl.deleteTextures(1, &m_to_aux);
4098 /** @brief Clean GL objects, test variables and GL errors.
4100 void StorageMultisampleTest::CleanPrograms()
4102 /* Shortcut for GL functionality. */
4103 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4105 /* Binding point. */
4108 /* Multisample texture preparation program. */
4111 gl.deleteProgram(m_po_ms);
4116 /* Auxiliary texture preparation program. */
4119 gl.deleteProgram(m_po_aux);
4125 /** @brief Clean GL objects, test variables and GL errors.
4127 void StorageMultisampleTest::CleanErrors()
4129 /* Shortcut for GL functionality. */
4130 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4132 /* Query all errors until GL_NO_ERROR occure. */
4133 while (GL_NO_ERROR != gl.getError())
4137 /** @brief Clean GL objects, test variables and GL errors.
4139 void StorageMultisampleTest::CleanVertexArray()
4141 /* Shortcut for GL functionality. */
4142 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4146 gl.bindVertexArray(0);
4148 gl.deleteVertexArrays(1, &m_vao);
4154 /** @brief Iterate Storage Multisample Test cases.
4156 * @return Iteration result.
4158 tcu::TestNode::IterateResult StorageMultisampleTest::iterate()
4160 /* Shortcut for GL functionality. */
4161 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4163 /* Get context setup. */
4164 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
4165 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
4167 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
4169 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
4174 /* Running tests. */
4176 bool is_error = false;
4180 PrepareVertexArray();
4182 // gl.enable(GL_MULTISAMPLE);
4184 is_ok &= LoopTestOverDOverS<glw::GLbyte, false>(true);
4185 is_ok &= LoopTestOverDOverS<glw::GLubyte, false>(true);
4186 is_ok &= LoopTestOverDOverS<glw::GLshort, false>(true);
4187 is_ok &= LoopTestOverDOverS<glw::GLushort, false>(true);
4188 is_ok &= LoopTestOverDOverS<glw::GLint, false>(false);
4189 is_ok &= LoopTestOverDOverS<glw::GLuint, false>(false);
4190 is_ok &= LoopTestOverDOverS<glw::GLubyte, true>(true);
4191 is_ok &= LoopTestOverDOverS<glw::GLushort, true>(true);
4192 is_ok &= LoopTestOverDOverS<glw::GLfloat, true>(false);
4201 CleanInputTexture();
4202 CleanAuxiliaryTexture();
4203 CleanFramebuffers();
4207 gl.disable(GL_MULTISAMPLE);
4209 /* Errors clean up. */
4210 while (gl.getError())
4213 /* Result's setup. */
4216 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
4222 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
4226 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
4233 /* Vertex shader source code. */
4234 const glw::GLchar* StorageMultisampleTest::s_vertex_shader = "#version 450\n"
4238 " switch(gl_VertexID)\n"
4241 " gl_Position = vec4(-1.0, 1.0, 0.0, 1.0);\n"
4244 " gl_Position = vec4( 1.0, 1.0, 0.0, 1.0);\n"
4247 " gl_Position = vec4(-1.0,-1.0, 0.0, 1.0);\n"
4250 " gl_Position = vec4( 1.0,-1.0, 0.0, 1.0);\n"
4255 /* Fragment shader source program. */
4256 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_head =
4259 "layout(pixel_center_integer) in vec4 gl_FragCoord;\n"
4262 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_2D_fdecl_lowp =
4263 "uniform sampler2D texture_input;\nout vec4 texture_output;\n";
4264 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_2D_idecl_lowp =
4265 "uniform isampler2D texture_input;\nout ivec4 texture_output;\n";
4266 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_2D_udecl_lowp =
4267 "uniform usampler2D texture_input;\nout uvec4 texture_output;\n";
4268 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_2D_fdecl_mediump =
4269 "uniform sampler2D texture_input;\nout vec4 texture_output;\n";
4270 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_2D_idecl_mediump =
4271 "uniform isampler2D texture_input;\nout ivec4 texture_output;\n";
4272 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_2D_udecl_mediump =
4273 "uniform usampler2D texture_input;\nout uvec4 texture_output;\n";
4274 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_2D_fdecl_highp =
4275 "uniform sampler2D texture_input;\nout vec4 texture_output;\n";
4276 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_2D_idecl_highp =
4277 "uniform isampler2D texture_input;\nout ivec4 texture_output;\n";
4278 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_2D_udecl_highp =
4279 "uniform usampler2D texture_input;\nout uvec4 texture_output;\n";
4281 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_3D_fdecl_lowp =
4282 "uniform sampler2DArray texture_input;\nout vec4 texture_output;\n";
4284 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_3D_idecl_lowp =
4285 "uniform isampler2DArray texture_input;\nout ivec4 texture_output;\n";
4287 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_3D_udecl_lowp =
4288 "uniform usampler2DArray texture_input;\nout uvec4 texture_output;\n";
4290 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_3D_fdecl_mediump =
4291 "uniform sampler2DArray texture_input;\nout vec4 texture_output;\n";
4293 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_3D_idecl_mediump =
4294 "uniform isampler2DArray texture_input;\nout ivec4 texture_output;\n";
4296 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_3D_udecl_mediump =
4297 "uniform usampler2DArray texture_input;\nout uvec4 texture_output;\n";
4299 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_3D_fdecl_highp =
4300 "uniform sampler2DArray texture_input;\nout vec4 texture_output;\n";
4302 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_3D_idecl_highp =
4303 "uniform isampler2DArray texture_input;\nout ivec4 texture_output;\n";
4305 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_ms_3D_udecl_highp =
4306 "uniform usampler2DArray texture_input;\nout uvec4 texture_output;\n";
4308 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_2D_fdecl_lowp =
4309 "uniform sampler2DMS texture_input;\nout vec4 texture_output;\n";
4310 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_2D_idecl_lowp =
4311 "uniform isampler2DMS texture_input;\nout ivec4 texture_output;\n";
4312 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_2D_udecl_lowp =
4313 "uniform usampler2DMS texture_input;\nout uvec4 texture_output;\n";
4315 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_2D_fdecl_mediump =
4316 "uniform sampler2DMS texture_input;\nout vec4 texture_output;\n";
4318 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_2D_idecl_mediump =
4319 "uniform isampler2DMS texture_input;\nout ivec4 texture_output;\n";
4321 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_2D_udecl_mediump =
4322 "uniform usampler2DMS texture_input;\nout uvec4 texture_output;\n";
4324 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_2D_fdecl_highp =
4325 "uniform sampler2DMS texture_input;\nout vec4 texture_output;\n";
4326 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_2D_idecl_highp =
4327 "uniform isampler2DMS texture_input;\nout ivec4 texture_output;\n";
4328 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_2D_udecl_highp =
4329 "uniform usampler2DMS texture_input;\nout uvec4 texture_output;\n";
4331 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_3D_fdecl_lowp =
4332 "uniform sampler2DMSArray texture_input;\nout vec4 texture_output;\n";
4334 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_3D_idecl_lowp =
4335 "uniform isampler2DMSArray texture_input;\nout ivec4 texture_output;\n";
4337 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_3D_udecl_lowp =
4338 "uniform usampler2DMSArray texture_input;\nout uvec4 texture_output;\n";
4340 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_3D_fdecl_mediump =
4341 "uniform sampler2DMSArray texture_input;\nout vec4 texture_output;\n";
4343 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_3D_idecl_mediump =
4344 "uniform isampler2DMSArray texture_input;\nout ivec4 texture_output;\n";
4346 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_3D_udecl_mediump =
4347 "uniform usampler2DMSArray texture_input;\nout uvec4 texture_output;\n";
4349 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_3D_fdecl_highp =
4350 "uniform sampler2DMSArray texture_input;\nout vec4 texture_output;\n";
4352 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_3D_idecl_highp =
4353 "uniform isampler2DMSArray texture_input;\nout ivec4 texture_output;\n";
4355 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_aux_3D_udecl_highp =
4356 "uniform usampler2DMSArray texture_input;\nout uvec4 texture_output;\n";
4358 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_tail_2D =
4362 " texture_output = texelFetch(texture_input, ivec2(gl_FragCoord.xy), 0);\n"
4365 const glw::GLchar* StorageMultisampleTest::s_fragment_shader_tail_3D =
4367 "uniform int texture_layer;\n"
4371 " texture_output = texelFetch(texture_input, ivec3(gl_FragCoord.xy, texture_layer), 0);\n"
4374 /******************************** Compressed SubImage Test Implementation ********************************/
4376 /** @brief Compressed SubImage Test constructor.
4378 * @param [in] context OpenGL context.
4380 CompressedSubImageTest::CompressedSubImageTest(deqp::Context& context)
4381 : deqp::TestCase(context, "textures_compressed_subimage", "Texture Compressed SubImage Test")
4384 , m_reference(DE_NULL)
4386 , m_reference_size(0)
4387 , m_reference_internalformat(0)
4389 /* Intentionally left blank. */
4392 /** @brief Create texture.
4394 * @param [in] target Texture target.
4396 void CompressedSubImageTest::CreateTextures(glw::GLenum target)
4398 /* Shortcut for GL functionality. */
4399 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4401 /* Auxiliary texture (for content creation). */
4402 gl.genTextures(1, &m_to_aux);
4403 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
4405 gl.bindTexture(target, m_to_aux);
4406 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
4408 /* Test texture (for data upload). */
4409 gl.genTextures(1, &m_to);
4410 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
4412 gl.bindTexture(target, m_to);
4413 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
4416 /** @brief Texture target selector.
4418 * @tparam D Texture dimenisons.
4420 * @return Texture target.
4423 glw::GLenum CompressedSubImageTest::TextureTarget<1>()
4425 return GL_TEXTURE_1D;
4429 glw::GLenum CompressedSubImageTest::TextureTarget<2>()
4431 return GL_TEXTURE_2D;
4435 glw::GLenum CompressedSubImageTest::TextureTarget<3>()
4437 return GL_TEXTURE_2D_ARRAY;
4440 /** @brief Prepare texture data for the auxiliary texture.
4442 * @tparam D Texture dimenisons.
4444 * @note parameters as passed to texImage*
4447 void CompressedSubImageTest::TextureImage<1>(glw::GLint internalformat)
4449 /* Shortcut for GL functionality. */
4450 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4452 gl.texImage1D(TextureTarget<1>(), 0, internalformat, s_texture_width, 0, GL_RGBA, GL_UNSIGNED_BYTE, s_texture_data);
4453 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
4456 /** @brief Prepare texture data for the auxiliary texture.
4458 * @tparam D Texture dimenisons.
4460 * @note parameters as passed to texImage*
4463 void CompressedSubImageTest::TextureImage<2>(glw::GLint internalformat)
4465 /* Shortcut for GL functionality. */
4466 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4468 gl.texImage2D(TextureTarget<2>(), 0, internalformat, s_texture_width, s_texture_height, 0, GL_RGBA,
4469 GL_UNSIGNED_BYTE, s_texture_data);
4470 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
4473 /** @brief Prepare texture data for the auxiliary texture.
4475 * @tparam D Texture dimenisons.
4477 * @note parameters as passed to texImage*
4480 void CompressedSubImageTest::TextureImage<3>(glw::GLint internalformat)
4482 /* Shortcut for GL functionality. */
4483 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4485 gl.texImage3D(TextureTarget<3>(), 0, internalformat, s_texture_width, s_texture_height, s_texture_depth, 0, GL_RGBA,
4486 GL_UNSIGNED_BYTE, s_texture_data);
4487 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage3D has failed");
4490 /** @brief Prepare texture data for the compressed texture.
4492 * @tparam D Texture dimenisons.
4494 * @param [in] internalformat Texture internal format.
4496 * @return True if tested function succeeded, false otherwise.
4499 bool CompressedSubImageTest::CompressedTextureSubImage<1>(glw::GLint internalformat)
4501 /* Shortcut for GL functionality. */
4502 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4504 /* Load texture image with tested function. */
4505 if (m_reference_size)
4507 gl.compressedTextureSubImage1D(m_to, 0, 0, s_texture_width, internalformat, m_reference_size, m_reference);
4511 /* For 1D version there is no specific compressed texture internal format spcified in OpenGL 4.5 core profile documentation.
4512 Only implementation depended specific internalformats may provide this functionality. As a result there may be no reference data to be substituted.
4513 Due to this reason there is no use of CompressedTextureSubImage1D and particulary it cannot be tested. */
4520 if (GL_NO_ERROR != (error = gl.getError()))
4522 m_context.getTestContext().getLog()
4523 << tcu::TestLog::Message << "glCompressedTextureSubImage1D unexpectedly generated error "
4524 << glu::getErrorStr(error) << " during the test with internal format "
4525 << glu::getTextureFormatStr(internalformat) << ". Test fails." << tcu::TestLog::EndMessage;
4533 /** @brief Prepare texture data for the compressed texture.
4535 * @tparam D Texture dimenisons.
4537 * @param [in] internalformat Texture internal format.
4539 * @return True if tested function succeeded, false otherwise.
4542 bool CompressedSubImageTest::CompressedTextureSubImage<2>(glw::GLint internalformat)
4544 /* Shortcut for GL functionality. */
4545 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4547 /* Load texture image with tested function. */
4548 gl.compressedTextureSubImage2D(m_to, 0, 0, 0, s_texture_width, s_texture_height, internalformat, m_reference_size,
4554 if (GL_NO_ERROR != (error = gl.getError()))
4556 m_context.getTestContext().getLog()
4557 << tcu::TestLog::Message << "glCompressedTextureSubImage2D unexpectedly generated error "
4558 << glu::getErrorStr(error) << " during the test with internal format "
4559 << glu::getTextureFormatStr(internalformat) << ". Test fails." << tcu::TestLog::EndMessage;
4567 /** @brief Prepare texture data for the compressed texture.
4569 * @tparam D Texture dimenisons.
4571 * @param [in] internalformat Texture internal format.
4573 * @return True if tested function succeeded, false otherwise.
4576 bool CompressedSubImageTest::CompressedTextureSubImage<3>(glw::GLint internalformat)
4578 /* Shortcut for GL functionality. */
4579 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4581 /* Load texture image with tested function. */
4582 gl.compressedTextureSubImage3D(m_to, 0, 0, 0, 0, s_texture_width, s_texture_height, s_texture_depth, internalformat,
4583 m_reference_size, m_reference);
4588 if (GL_NO_ERROR != (error = gl.getError()))
4590 m_context.getTestContext().getLog()
4591 << tcu::TestLog::Message << "glCompressedTextureSubImage2D unexpectedly generated error "
4592 << glu::getErrorStr(error) << " during the test with internal format "
4593 << glu::getTextureFormatStr(internalformat) << ". Test fails." << tcu::TestLog::EndMessage;
4600 /** @brief Prepare the reference data.
4602 * @tparam D Texture dimenisons.
4604 template <glw::GLuint D>
4605 void CompressedSubImageTest::PrepareReferenceData(glw::GLenum internalformat)
4607 /* Shortcut for GL functionality. */
4608 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4610 /* Using OpenGL to compress raw data. */
4611 gl.bindTexture(TextureTarget<D>(), m_to_aux);
4612 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
4614 TextureImage<D>(internalformat);
4616 /* Sanity checks. */
4617 if (DE_NULL != m_reference)
4622 /* Check that really compressed texture. */
4623 glw::GLint is_compressed_texture = 0;
4624 gl.getTexLevelParameteriv(TextureTarget<D>(), 0, GL_TEXTURE_COMPRESSED, &is_compressed_texture);
4626 if (is_compressed_texture)
4628 /* Query texture size. */
4629 glw::GLint compressed_texture_size = 0;
4630 gl.getTexLevelParameteriv(TextureTarget<D>(), 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &compressed_texture_size);
4632 /* If compressed then download. */
4633 if (compressed_texture_size)
4635 /* Prepare storage. */
4636 m_reference = new glw::GLubyte[compressed_texture_size];
4638 if (DE_NULL != m_reference)
4640 m_reference_size = compressed_texture_size;
4647 /* Download compressed texture image. */
4648 gl.getCompressedTexImage(TextureTarget<D>(), 0, m_reference);
4649 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
4654 /** @brief Prepare texture storage.
4656 * @tparam D Texture dimenisons.
4658 * @param [in] internalformat Texture internal format.
4661 void CompressedSubImageTest::PrepareStorage<1>(glw::GLenum internalformat)
4663 /* Shortcut for GL functionality. */
4664 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4666 gl.bindTexture(TextureTarget<1>(), m_to);
4667 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
4669 gl.texImage1D(TextureTarget<1>(), 0, internalformat, s_texture_width, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
4670 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
4673 /** @brief Prepare texture storage.
4675 * @tparam D Texture dimenisons.
4677 * @param [in] internalformat Texture internal format.
4680 void CompressedSubImageTest::PrepareStorage<2>(glw::GLenum internalformat)
4682 /* Shortcut for GL functionality. */
4683 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4685 gl.bindTexture(TextureTarget<2>(), m_to);
4686 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
4688 gl.texImage2D(TextureTarget<2>(), 0, internalformat, s_texture_width, s_texture_height, 0, GL_RGBA,
4689 GL_UNSIGNED_BYTE, NULL);
4690 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
4693 /** @brief Prepare texture storage.
4695 * @tparam D Texture dimenisons.
4697 * @param [in] internalformat Texture internal format.
4700 void CompressedSubImageTest::PrepareStorage<3>(glw::GLenum internalformat)
4702 /* Shortcut for GL functionality. */
4703 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4705 gl.bindTexture(TextureTarget<3>(), m_to);
4706 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
4708 gl.texImage3D(TextureTarget<3>(), 0, internalformat, s_texture_width, s_texture_height, s_texture_depth, 0, GL_RGBA,
4709 GL_UNSIGNED_BYTE, NULL);
4710 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
4713 /** @brief Compre results with the reference.
4716 * @tparam S Size (# of components).
4717 * @tparam N Is normalized.
4719 * @param [in] target Texture target.
4720 * @param [in] internalformat Texture internal format.
4722 * @return True if equal, false otherwise.
4724 bool CompressedSubImageTest::CheckData(glw::GLenum target, glw::GLenum internalformat)
4726 /* Shortcut for GL functionality. */
4727 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4729 /* Check texture content with reference. */
4730 m_result = new glw::GLubyte[m_reference_size];
4732 if (DE_NULL == m_result)
4737 gl.getCompressedTexImage(target, 0, m_result);
4738 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
4740 for (glw::GLuint i = 0; i < m_reference_size; ++i)
4742 if (m_reference[i] != m_result[i])
4744 m_context.getTestContext().getLog()
4745 << tcu::TestLog::Message << "glCompressedTextureSubImage*D created texture with data "
4746 << DataToString(m_reference_size, m_reference) << " however texture contains data "
4747 << DataToString(m_reference_size, m_result) << ". Texture target was "
4748 << glu::getTextureTargetStr(target) << " and internal format was "
4749 << glu::getTextureFormatStr(internalformat) << ". Test fails." << tcu::TestLog::EndMessage;
4758 /** @brief Test case function.
4760 * @tparam D Number of texture dimensions.
4762 * @param [in] internal format Texture internal format.
4764 * @return True if test succeeded, false otherwise.
4766 template <glw::GLuint D>
4767 bool CompressedSubImageTest::Test(glw::GLenum internalformat)
4769 /* Create texture image. */
4770 CreateTextures(TextureTarget<D>());
4771 PrepareReferenceData<D>(internalformat);
4772 PrepareStorage<D>(internalformat);
4774 /* Setup data with CompressedTextureSubImage<D>D function and check for errors. */
4775 if (!CompressedTextureSubImage<D>(internalformat))
4782 /* If compressed reference data was generated than compare values. */
4785 if (!CheckData(TextureTarget<D>(), internalformat))
4798 /** @brief Clean GL objects, test variables and GL errors.
4800 void CompressedSubImageTest::CleanAll()
4802 /* Shortcut for GL functionality. */
4803 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4808 gl.deleteTextures(1, &m_to);
4815 gl.deleteTextures(1, &m_to_aux);
4820 /* Reference data storage. */
4821 if (DE_NULL != m_reference)
4823 delete[] m_reference;
4825 m_reference = DE_NULL;
4828 if (DE_NULL != m_result)
4835 m_reference_size = 0;
4838 while (GL_NO_ERROR != gl.getError())
4842 /** @brief Convert raw data into string for logging purposes.
4844 * @param [in] count Count of the data.
4845 * @param [in] data Raw data.
4847 * @return String representation of data.
4849 std::string CompressedSubImageTest::DataToString(glw::GLuint count, const glw::GLubyte data[])
4851 std::string data_str = "[";
4853 for (glw::GLuint i = 0; i < count; ++i)
4855 std::stringstream int_sstream;
4857 int_sstream << unsigned(data[i]);
4859 data_str.append(int_sstream.str());
4863 data_str.append(", ");
4867 data_str.append("]");
4874 /** @brief Iterate Compressed SubImage Test cases.
4876 * @return Iteration result.
4878 tcu::TestNode::IterateResult CompressedSubImageTest::iterate()
4880 /* Shortcut for GL functionality. */
4881 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4883 /* Get context setup. */
4884 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
4885 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
4887 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
4889 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
4894 /* Running tests. */
4896 bool is_error = false;
4900 is_ok &= Test<1>(GL_COMPRESSED_RGB);
4902 is_ok &= Test<2>(GL_COMPRESSED_RED_RGTC1);
4903 is_ok &= Test<2>(GL_COMPRESSED_SIGNED_RED_RGTC1);
4904 is_ok &= Test<2>(GL_COMPRESSED_RG_RGTC2);
4905 is_ok &= Test<2>(GL_COMPRESSED_SIGNED_RG_RGTC2);
4906 is_ok &= Test<2>(GL_COMPRESSED_RGBA_BPTC_UNORM);
4907 is_ok &= Test<2>(GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM);
4908 is_ok &= Test<2>(GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT);
4909 is_ok &= Test<2>(GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT);
4910 is_ok &= Test<2>(GL_COMPRESSED_RGB8_ETC2);
4911 is_ok &= Test<2>(GL_COMPRESSED_SRGB8_ETC2);
4912 is_ok &= Test<2>(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2);
4913 is_ok &= Test<2>(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2);
4914 is_ok &= Test<2>(GL_COMPRESSED_RGBA8_ETC2_EAC);
4915 is_ok &= Test<2>(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC);
4916 is_ok &= Test<2>(GL_COMPRESSED_R11_EAC);
4917 is_ok &= Test<2>(GL_COMPRESSED_SIGNED_R11_EAC);
4918 is_ok &= Test<2>(GL_COMPRESSED_RG11_EAC);
4919 is_ok &= Test<2>(GL_COMPRESSED_SIGNED_RG11_EAC);
4921 is_ok &= Test<3>(GL_COMPRESSED_RED_RGTC1);
4922 is_ok &= Test<3>(GL_COMPRESSED_SIGNED_RED_RGTC1);
4923 is_ok &= Test<3>(GL_COMPRESSED_RG_RGTC2);
4924 is_ok &= Test<3>(GL_COMPRESSED_SIGNED_RG_RGTC2);
4925 is_ok &= Test<3>(GL_COMPRESSED_RGBA_BPTC_UNORM);
4926 is_ok &= Test<3>(GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM);
4927 is_ok &= Test<3>(GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT);
4928 is_ok &= Test<3>(GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT);
4929 is_ok &= Test<3>(GL_COMPRESSED_RGB8_ETC2);
4930 is_ok &= Test<3>(GL_COMPRESSED_SRGB8_ETC2);
4931 is_ok &= Test<3>(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2);
4932 is_ok &= Test<3>(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2);
4933 is_ok &= Test<3>(GL_COMPRESSED_RGBA8_ETC2_EAC);
4934 is_ok &= Test<3>(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC);
4935 is_ok &= Test<3>(GL_COMPRESSED_R11_EAC);
4936 is_ok &= Test<3>(GL_COMPRESSED_SIGNED_R11_EAC);
4937 is_ok &= Test<3>(GL_COMPRESSED_RG11_EAC);
4938 is_ok &= Test<3>(GL_COMPRESSED_SIGNED_RG11_EAC);
4949 /* Errors clean up. */
4950 while (gl.getError())
4953 /* Result's setup. */
4956 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
4962 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
4966 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
4973 /** Reference data. */
4974 const glw::GLubyte CompressedSubImageTest::s_texture_data[] = {
4975 0x00, 0x00, 0x00, 0xFF, 0x7f, 0x7f, 0x7f, 0x00, 0xc3, 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0x00,
4976 0x88, 0x00, 0x15, 0xFF, 0xed, 0x1c, 0x24, 0x00, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x00, 0x00,
4977 0xc8, 0xbf, 0xe7, 0xFF, 0x70, 0x92, 0xbe, 0x00, 0x99, 0xd9, 0xea, 0xff, 0xb5, 0xe6, 0x1d, 0x00,
4978 0xa3, 0x49, 0xa4, 0xFF, 0x3f, 0x48, 0xcc, 0x00, 0x00, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0x00,
4980 0xa3, 0x49, 0xa4, 0xFF, 0xc8, 0xbf, 0xe7, 0x00, 0x88, 0x00, 0x15, 0xff, 0x00, 0x00, 0x00, 0x00,
4981 0x3f, 0x48, 0xcc, 0xFF, 0x70, 0x92, 0xbe, 0x00, 0xed, 0x1c, 0x24, 0xff, 0x7f, 0x7f, 0x7f, 0x00,
4982 0x00, 0xa2, 0xe8, 0xFF, 0x99, 0xd9, 0xea, 0x00, 0xff, 0x7f, 0x27, 0xff, 0xc3, 0xc3, 0xc3, 0x00,
4983 0x22, 0xb1, 0x4c, 0xFF, 0xb5, 0xe6, 0x1d, 0x00, 0xff, 0xf2, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00,
4985 0x22, 0xb1, 0x4c, 0xFF, 0x00, 0xa2, 0xe8, 0x00, 0x3f, 0x48, 0xcc, 0xff, 0xa3, 0x49, 0xa4, 0x00,
4986 0xb5, 0xe6, 0x1d, 0xFF, 0x99, 0xd9, 0xea, 0x00, 0x70, 0x92, 0xbe, 0xff, 0xc8, 0xbf, 0xe7, 0x00,
4987 0xff, 0xf2, 0x00, 0xFF, 0xff, 0x7f, 0x27, 0x00, 0xed, 0x1c, 0x24, 0xff, 0x88, 0x00, 0x15, 0x00,
4988 0xff, 0xff, 0xff, 0xFF, 0xc3, 0xc3, 0xc3, 0x00, 0x7f, 0x7f, 0x7f, 0xff, 0x00, 0x00, 0x00, 0x00,
4990 0xff, 0xff, 0xff, 0xFF, 0xff, 0xf2, 0x00, 0x00, 0xb5, 0xe6, 0x1d, 0xff, 0x22, 0xb1, 0x4c, 0x00,
4991 0xc3, 0xc3, 0xc3, 0xFF, 0xff, 0x7f, 0x27, 0x00, 0x99, 0xd9, 0xea, 0xff, 0x00, 0xa2, 0xe8, 0x00,
4992 0x7f, 0x7f, 0x7f, 0xFF, 0xed, 0x1c, 0x24, 0x00, 0x70, 0x92, 0xbe, 0xff, 0x3f, 0x48, 0xcc, 0x00,
4993 0x00, 0x00, 0x00, 0xFF, 0x88, 0x00, 0x15, 0x00, 0xc8, 0xbf, 0xe7, 0xff, 0xa3, 0x49, 0xa4, 0x00
4996 /** Reference data parameters. */
4997 const glw::GLuint CompressedSubImageTest::s_texture_width = 4;
4998 const glw::GLuint CompressedSubImageTest::s_texture_height = 4;
4999 const glw::GLuint CompressedSubImageTest::s_texture_depth = 4;
5001 /******************************** Copy SubImage Test Implementation ********************************/
5003 /** @brief Compressed SubImage Test constructor.
5005 * @param [in] context OpenGL context.
5007 CopyTest::CopyTest(deqp::Context& context)
5008 : deqp::TestCase(context, "textures_copy", "Texture Copy Test")
5014 /* Intentionally left blank. */
5017 /** @brief Texture target selector.
5019 * @tparam D Texture dimenisons.
5021 * @return Texture target.
5024 glw::GLenum CopyTest::TextureTarget<1>()
5026 return GL_TEXTURE_1D;
5029 glw::GLenum CopyTest::TextureTarget<2>()
5031 return GL_TEXTURE_2D;
5034 glw::GLenum CopyTest::TextureTarget<3>()
5036 return GL_TEXTURE_3D;
5039 /** @brief Copy texture, check errors and log.
5041 * @note Parameters as passed to CopyTextureSubImage*D
5043 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
5045 bool CopyTest::CopyTextureSubImage1DAndCheckErrors(glw::GLuint texture, glw::GLint level, glw::GLint xoffset,
5046 glw::GLint x, glw::GLint y, glw::GLsizei width)
5048 /* Shortcut for GL functionality. */
5049 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5051 gl.readBuffer(GL_COLOR_ATTACHMENT0);
5052 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
5054 gl.copyTextureSubImage1D(texture, level, xoffset, x, y, width);
5059 if (GL_NO_ERROR != (error = gl.getError()))
5061 m_context.getTestContext().getLog() << tcu::TestLog::Message
5062 << "glCopyTextureSubImage1D unexpectedly generated error "
5063 << glu::getErrorStr(error) << ". Test fails." << tcu::TestLog::EndMessage;
5071 /** @brief Copy texture, check errors and log.
5073 * @note Parameters as passed to CopyTextureSubImage*D
5075 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
5077 bool CopyTest::CopyTextureSubImage2DAndCheckErrors(glw::GLuint texture, glw::GLint level, glw::GLint xoffset,
5078 glw::GLint yoffset, glw::GLint x, glw::GLint y, glw::GLsizei width,
5079 glw::GLsizei height)
5081 /* Shortcut for GL functionality. */
5082 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5084 gl.readBuffer(GL_COLOR_ATTACHMENT0);
5085 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
5087 gl.copyTextureSubImage2D(texture, level, xoffset, yoffset, x, y, width, height);
5092 if (GL_NO_ERROR != (error = gl.getError()))
5094 m_context.getTestContext().getLog() << tcu::TestLog::Message
5095 << "glCopyTextureSubImage2D unexpectedly generated error "
5096 << glu::getErrorStr(error) << ". Test fails." << tcu::TestLog::EndMessage;
5104 /** @brief Copy texture, check errors and log.
5106 * @note Parameters as passed to CopyTextureSubImage*D
5108 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
5110 bool CopyTest::CopyTextureSubImage3DAndCheckErrors(glw::GLuint texture, glw::GLint level, glw::GLint xoffset,
5111 glw::GLint yoffset, glw::GLint zoffset, glw::GLint x, glw::GLint y,
5112 glw::GLsizei width, glw::GLsizei height)
5114 /* Shortcut for GL functionality. */
5115 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5117 gl.readBuffer(GL_COLOR_ATTACHMENT0 + zoffset);
5118 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
5120 gl.copyTextureSubImage3D(texture, level, xoffset, yoffset, zoffset, x, y, width, height);
5125 if (GL_NO_ERROR != (error = gl.getError()))
5127 m_context.getTestContext().getLog() << tcu::TestLog::Message
5128 << "glCopyTextureSubImage3D unexpectedly generated error "
5129 << glu::getErrorStr(error) << ". Test fails." << tcu::TestLog::EndMessage;
5137 /** @brief Create texture.
5139 * @tparam D Dimmensions.
5142 void CopyTest::CreateSourceTexture<1>()
5144 /* Shortcut for GL functionality. */
5145 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5147 gl.genTextures(1, &m_to_src);
5148 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
5150 gl.bindTexture(TextureTarget<1>(), m_to_src);
5151 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
5153 gl.texImage1D(TextureTarget<1>(), 0, GL_RGBA8, s_texture_width, 0, GL_RGBA, GL_UNSIGNED_BYTE, s_texture_data);
5154 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D call failed.");
5157 /** @brief Create texture.
5159 * @tparam D Dimmensions.
5162 void CopyTest::CreateSourceTexture<2>()
5164 /* Shortcut for GL functionality. */
5165 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5167 gl.genTextures(1, &m_to_src);
5168 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
5170 gl.bindTexture(TextureTarget<2>(), m_to_src);
5171 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
5173 gl.texImage2D(TextureTarget<2>(), 0, GL_RGBA8, s_texture_width, s_texture_height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
5175 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D call failed.");
5178 /** @brief Create texture.
5180 * @tparam D Dimmensions.
5183 void CopyTest::CreateSourceTexture<3>()
5185 /* Shortcut for GL functionality. */
5186 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5188 gl.genTextures(1, &m_to_src);
5189 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
5191 gl.bindTexture(TextureTarget<3>(), m_to_src);
5192 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
5194 gl.texImage3D(TextureTarget<3>(), 0, GL_RGBA8, s_texture_width, s_texture_height, s_texture_depth, 0, GL_RGBA,
5195 GL_UNSIGNED_BYTE, s_texture_data);
5196 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D call failed.");
5199 /** @brief Create texture.
5201 * @tparam D Dimmensions.
5204 void CopyTest::CreateDestinationTexture<1>()
5206 /* Shortcut for GL functionality. */
5207 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5209 gl.genTextures(1, &m_to_dst);
5210 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
5212 gl.bindTexture(TextureTarget<1>(), m_to_dst);
5213 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
5215 gl.texImage1D(TextureTarget<1>(), 0, GL_RGBA8, s_texture_width, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL);
5216 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D call failed.");
5219 /** @brief Create texture.
5221 * @tparam D Dimmensions.
5224 void CopyTest::CreateDestinationTexture<2>()
5226 /* Shortcut for GL functionality. */
5227 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5229 gl.genTextures(1, &m_to_dst);
5230 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
5232 gl.bindTexture(TextureTarget<2>(), m_to_dst);
5233 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
5235 gl.texImage2D(TextureTarget<2>(), 0, GL_RGBA8, s_texture_width, s_texture_height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
5237 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D call failed.");
5240 /** @brief Create texture.
5242 * @tparam D Dimmensions.
5245 void CopyTest::CreateDestinationTexture<3>()
5247 /* Shortcut for GL functionality. */
5248 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5250 gl.genTextures(1, &m_to_dst);
5251 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
5253 gl.bindTexture(TextureTarget<3>(), m_to_dst);
5254 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
5256 gl.texImage3D(TextureTarget<3>(), 0, GL_RGBA8, s_texture_width, s_texture_height, s_texture_depth, 0, GL_RGBA,
5257 GL_UNSIGNED_BYTE, DE_NULL);
5258 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D call failed.");
5261 /** @brief Create framebuffer.
5263 * @tparam D Dimmensions.
5266 void CopyTest::CreateSourceFramebuffer<1>()
5268 /* Shortcut for GL functionality. */
5269 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5271 /* Prepare framebuffer. */
5272 gl.genFramebuffers(1, &m_fbo);
5273 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
5275 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
5276 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
5278 gl.framebufferTexture1D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, TextureTarget<1>(), m_to_src, 0);
5279 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferTexture1D call failed.");
5281 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
5286 gl.viewport(0, 0, s_texture_width, 1);
5287 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
5290 /** @brief Create framebuffer.
5292 * @tparam D Dimmensions.
5295 void CopyTest::CreateSourceFramebuffer<2>()
5297 /* Shortcut for GL functionality. */
5298 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5300 /* Prepare framebuffer. */
5301 gl.genFramebuffers(1, &m_fbo);
5302 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
5304 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
5305 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
5307 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, TextureTarget<2>(), m_to_src, 0);
5308 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferTexture1D call failed.");
5310 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
5315 gl.viewport(0, 0, s_texture_width, s_texture_height);
5316 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
5319 /** @brief Create framebuffer.
5321 * @tparam D Dimmensions.
5324 void CopyTest::CreateSourceFramebuffer<3>()
5326 /* Shortcut for GL functionality. */
5327 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5329 /* Prepare framebuffer. */
5330 gl.genFramebuffers(1, &m_fbo);
5331 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
5333 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
5334 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
5336 for (glw::GLuint i = 0; i < s_texture_depth; ++i)
5338 gl.framebufferTexture3D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, TextureTarget<3>(), m_to_src, 0, i);
5339 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferTexture1D call failed.");
5342 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
5347 gl.viewport(0, 0, s_texture_width, s_texture_height);
5348 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
5351 /** @brief Dispatch function to create test objects */
5352 template <glw::GLuint D>
5353 void CopyTest::CreateAll()
5355 CreateSourceTexture<D>();
5356 CreateSourceFramebuffer<D>();
5357 CreateDestinationTexture<D>();
5360 /** @brief Test function */
5362 bool CopyTest::Test<1>()
5368 result &= CopyTextureSubImage1DAndCheckErrors(m_to_dst, 0, 0, 0, 0, s_texture_width / 2);
5369 result &= CopyTextureSubImage1DAndCheckErrors(m_to_dst, 0, s_texture_width / 2, s_texture_width / 2, 0,
5370 s_texture_width / 2);
5372 result &= CheckData(TextureTarget<1>(), 4 /* RGBA */ * s_texture_width);
5379 /** @brief Test function */
5381 bool CopyTest::Test<2>()
5387 result &= CopyTextureSubImage2DAndCheckErrors(m_to_dst, 0, 0, 0, 0, 0, s_texture_width / 2, s_texture_height / 2);
5388 result &= CopyTextureSubImage2DAndCheckErrors(m_to_dst, 0, s_texture_width / 2, 0, s_texture_width / 2, 0,
5389 s_texture_width / 2, s_texture_height / 2);
5390 result &= CopyTextureSubImage2DAndCheckErrors(m_to_dst, 0, 0, s_texture_height / 2, 0, s_texture_height / 2,
5391 s_texture_width / 2, s_texture_height / 2);
5393 CopyTextureSubImage2DAndCheckErrors(m_to_dst, 0, s_texture_width / 2, s_texture_height / 2, s_texture_width / 2,
5394 s_texture_height / 2, s_texture_width / 2, s_texture_height / 2);
5396 result &= CheckData(TextureTarget<2>(), 4 /* RGBA */ * s_texture_width * s_texture_height);
5403 /** @brief Test function */
5405 bool CopyTest::Test<3>()
5411 for (glw::GLuint i = 0; i < s_texture_depth; ++i)
5414 CopyTextureSubImage3DAndCheckErrors(m_to_dst, 0, 0, 0, i, 0, 0, s_texture_width / 2, s_texture_height / 2);
5415 result &= CopyTextureSubImage3DAndCheckErrors(m_to_dst, 0, s_texture_width / 2, 0, i, s_texture_width / 2, 0,
5416 s_texture_width / 2, s_texture_height / 2);
5417 result &= CopyTextureSubImage3DAndCheckErrors(m_to_dst, 0, 0, s_texture_height / 2, i, 0, s_texture_height / 2,
5418 s_texture_width / 2, s_texture_height / 2);
5419 result &= CopyTextureSubImage3DAndCheckErrors(m_to_dst, 0, s_texture_width / 2, s_texture_height / 2, i,
5420 s_texture_width / 2, s_texture_height / 2, s_texture_width / 2,
5421 s_texture_height / 2);
5424 result &= CheckData(TextureTarget<3>(), 4 /* RGBA */ * s_texture_width * s_texture_height * s_texture_depth);
5431 /** @brief Compre results with the reference.
5433 * @param [in] target Texture target.
5434 * @param [in] size Size of the buffer.
5436 * @return True if equal, false otherwise.
5438 bool CopyTest::CheckData(glw::GLenum target, glw::GLuint size)
5440 /* Shortcut for GL functionality. */
5441 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5443 /* Check texture content with reference. */
5444 m_result = new glw::GLubyte[size];
5446 if (DE_NULL == m_result)
5451 gl.getTexImage(target, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_result);
5452 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
5454 for (glw::GLuint i = 0; i < size; ++i)
5456 if (s_texture_data[i] != m_result[i])
5458 m_context.getTestContext().getLog()
5459 << tcu::TestLog::Message << "glCopyTextureSubImage*D created texture with data "
5460 << DataToString(size, s_texture_data) << " however texture contains data "
5461 << DataToString(size, m_result) << ". Texture target was " << glu::getTextureTargetStr(target)
5462 << ". Test fails." << tcu::TestLog::EndMessage;
5471 /** @brief Convert raw data into string for logging purposes.
5473 * @param [in] count Count of the data.
5474 * @param [in] data Raw data.
5476 * @return String representation of data.
5478 std::string CopyTest::DataToString(glw::GLuint count, const glw::GLubyte data[])
5480 std::string data_str = "[";
5482 for (glw::GLuint i = 0; i < count; ++i)
5484 std::stringstream int_sstream;
5486 int_sstream << unsigned(data[i]);
5488 data_str.append(int_sstream.str());
5492 data_str.append(", ");
5496 data_str.append("]");
5503 /** @brief Clean GL objects, test variables and GL errors.
5505 void CopyTest::CleanAll()
5507 /* Shortcut for GL functionality. */
5508 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5512 gl.deleteFramebuffers(1, &m_fbo);
5519 gl.deleteTextures(1, &m_to_src);
5526 gl.deleteTextures(1, &m_to_dst);
5531 if (DE_NULL == m_result)
5538 while (GL_NO_ERROR != gl.getError())
5542 /** @brief Iterate Copy Test cases.
5544 * @return Iteration result.
5546 tcu::TestNode::IterateResult CopyTest::iterate()
5548 /* Get context setup. */
5549 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
5550 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
5552 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
5554 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
5559 /* Running tests. */
5561 bool is_error = false;
5578 /* Result's setup. */
5581 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
5587 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
5591 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
5598 /** Reference data. */
5599 const glw::GLubyte CopyTest::s_texture_data[] = {
5600 0x00, 0x00, 0x00, 0xFF, 0x7f, 0x7f, 0x7f, 0x00, 0xc3, 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0x00,
5601 0x88, 0x00, 0x15, 0xFF, 0xed, 0x1c, 0x24, 0x00, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x00, 0x00,
5602 0xc8, 0xbf, 0xe7, 0xFF, 0x70, 0x92, 0xbe, 0x00, 0x99, 0xd9, 0xea, 0xff, 0xb5, 0xe6, 0x1d, 0x00,
5603 0xa3, 0x49, 0xa4, 0xFF, 0x3f, 0x48, 0xcc, 0x00, 0x00, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0x00,
5605 0xa3, 0x49, 0xa4, 0xFF, 0xc8, 0xbf, 0xe7, 0x00, 0x88, 0x00, 0x15, 0xff, 0x00, 0x00, 0x00, 0x00,
5606 0x3f, 0x48, 0xcc, 0xFF, 0x70, 0x92, 0xbe, 0x00, 0xed, 0x1c, 0x24, 0xff, 0x7f, 0x7f, 0x7f, 0x00,
5607 0x00, 0xa2, 0xe8, 0xFF, 0x99, 0xd9, 0xea, 0x00, 0xff, 0x7f, 0x27, 0xff, 0xc3, 0xc3, 0xc3, 0x00,
5608 0x22, 0xb1, 0x4c, 0xFF, 0xb5, 0xe6, 0x1d, 0x00, 0xff, 0xf2, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00,
5610 0x22, 0xb1, 0x4c, 0xFF, 0x00, 0xa2, 0xe8, 0x00, 0x3f, 0x48, 0xcc, 0xff, 0xa3, 0x49, 0xa4, 0x00,
5611 0xb5, 0xe6, 0x1d, 0xFF, 0x99, 0xd9, 0xea, 0x00, 0x70, 0x92, 0xbe, 0xff, 0xc8, 0xbf, 0xe7, 0x00,
5612 0xff, 0xf2, 0x00, 0xFF, 0xff, 0x7f, 0x27, 0x00, 0xed, 0x1c, 0x24, 0xff, 0x88, 0x00, 0x15, 0x00,
5613 0xff, 0xff, 0xff, 0xFF, 0xc3, 0xc3, 0xc3, 0x00, 0x7f, 0x7f, 0x7f, 0xff, 0x00, 0x00, 0x00, 0x00,
5615 0xff, 0xff, 0xff, 0xFF, 0xff, 0xf2, 0x00, 0x00, 0xb5, 0xe6, 0x1d, 0xff, 0x22, 0xb1, 0x4c, 0x00,
5616 0xc3, 0xc3, 0xc3, 0xFF, 0xff, 0x7f, 0x27, 0x00, 0x99, 0xd9, 0xea, 0xff, 0x00, 0xa2, 0xe8, 0x00,
5617 0x7f, 0x7f, 0x7f, 0xFF, 0xed, 0x1c, 0x24, 0x00, 0x70, 0x92, 0xbe, 0xff, 0x3f, 0x48, 0xcc, 0x00,
5618 0x00, 0x00, 0x00, 0xFF, 0x88, 0x00, 0x15, 0x00, 0xc8, 0xbf, 0xe7, 0xff, 0xa3, 0x49, 0xa4, 0x00
5621 /** Reference data parameters. */
5622 const glw::GLuint CopyTest::s_texture_width = 4;
5623 const glw::GLuint CopyTest::s_texture_height = 4;
5624 const glw::GLuint CopyTest::s_texture_depth = 4;
5626 /******************************** Get Set Parameter Test Implementation ********************************/
5628 /** @brief Get Set Parameter Test constructor.
5630 * @param [in] context OpenGL context.
5632 GetSetParameterTest::GetSetParameterTest(deqp::Context& context)
5633 : deqp::TestCase(context, "textures_get_set_parameter", "Texture Get Set Parameter Test")
5635 /* Intentionally left blank. */
5638 /** @brief Iterate Get Set Parameter Test cases.
5640 * @return Iteration result.
5642 tcu::TestNode::IterateResult GetSetParameterTest::iterate()
5644 /* Shortcut for GL functionality. */
5645 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5647 /* Get context setup. */
5648 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
5649 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
5651 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
5653 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
5658 /* Running tests. */
5660 bool is_error = false;
5663 glw::GLuint texture = 0;
5667 gl.genTextures(1, &texture);
5668 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
5670 gl.bindTexture(GL_TEXTURE_3D, texture);
5671 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
5674 glw::GLenum name = GL_DEPTH_STENCIL_TEXTURE_MODE;
5675 glw::GLint value_src = GL_DEPTH_COMPONENT;
5676 glw::GLint value_dst = 0;
5678 gl.textureParameteri(texture, name, value_src);
5679 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
5681 gl.getTextureParameteriv(texture, name, &value_dst);
5682 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
5684 is_ok &= CompareAndLog(value_src, value_dst, name);
5688 glw::GLenum name = GL_TEXTURE_BASE_LEVEL;
5689 glw::GLint value_src = 2;
5690 glw::GLint value_dst = 0;
5692 gl.textureParameteri(texture, name, value_src);
5693 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
5695 gl.getTextureParameteriv(texture, name, &value_dst);
5696 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
5698 is_ok &= CompareAndLog(value_src, value_dst, name);
5702 glw::GLenum name = GL_TEXTURE_BORDER_COLOR;
5703 glw::GLfloat value_src[4] = { 0.25, 0.5, 0.75, 1.0 };
5704 glw::GLfloat value_dst[4] = {};
5706 gl.textureParameterfv(texture, name, value_src);
5707 is_ok &= CheckErrorAndLog("glTextureParameterfv", name);
5709 gl.getTextureParameterfv(texture, name, value_dst);
5710 is_ok &= CheckErrorAndLog("glGetTextureParameterfv", name);
5712 is_ok &= CompareAndLog(value_src, value_dst, name);
5716 glw::GLenum name = GL_TEXTURE_BORDER_COLOR;
5717 glw::GLint value_src[4] = { 0, 64, -64, -32 };
5718 glw::GLint value_dst[4] = {};
5720 gl.textureParameterIiv(texture, name, value_src);
5721 is_ok &= CheckErrorAndLog("glTextureParameterIiv", name);
5723 gl.getTextureParameterIiv(texture, name, value_dst);
5724 is_ok &= CheckErrorAndLog("glGetTextureParameterIiv", name);
5726 is_ok &= CompareAndLog(value_src, value_dst, name);
5730 glw::GLenum name = GL_TEXTURE_BORDER_COLOR;
5731 glw::GLuint value_src[4] = { 0, 64, 128, 192 };
5732 glw::GLuint value_dst[4] = {};
5734 gl.textureParameterIuiv(texture, name, value_src);
5735 is_ok &= CheckErrorAndLog("glTextureParameterIuiv", name);
5737 gl.getTextureParameterIuiv(texture, name, value_dst);
5738 is_ok &= CheckErrorAndLog("glGetTextureParameterIuiv", name);
5740 is_ok &= CompareAndLog(value_src, value_dst, name);
5744 glw::GLenum name = GL_TEXTURE_COMPARE_FUNC;
5745 glw::GLint value_src = GL_LEQUAL;
5746 glw::GLint value_dst = 0;
5748 gl.textureParameteri(texture, name, value_src);
5749 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
5751 gl.getTextureParameteriv(texture, name, &value_dst);
5752 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
5754 is_ok &= CompareAndLog(value_src, value_dst, name);
5758 glw::GLenum name = GL_TEXTURE_COMPARE_MODE;
5759 glw::GLint value_src = GL_COMPARE_REF_TO_TEXTURE;
5760 glw::GLint value_dst = 0;
5762 gl.textureParameteri(texture, name, value_src);
5763 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
5765 gl.getTextureParameteriv(texture, name, &value_dst);
5766 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
5768 is_ok &= CompareAndLog(value_src, value_dst, name);
5772 glw::GLenum name = GL_TEXTURE_LOD_BIAS;
5773 glw::GLfloat value_src = -2.f;
5774 glw::GLfloat value_dst = 0.f;
5776 gl.textureParameterf(texture, name, value_src);
5777 is_ok &= CheckErrorAndLog("glTextureParameterf", name);
5779 gl.getTextureParameterfv(texture, name, &value_dst);
5780 is_ok &= CheckErrorAndLog("glGetTextureParameterfv", name);
5782 is_ok &= CompareAndLog(value_src, value_dst, name);
5786 glw::GLenum name = GL_TEXTURE_MIN_FILTER;
5787 glw::GLint value_src = GL_LINEAR_MIPMAP_NEAREST;
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_MAG_FILTER;
5801 glw::GLint value_src = GL_NEAREST;
5802 glw::GLint value_dst = 0;
5804 gl.textureParameteri(texture, name, value_src);
5805 is_ok &= CheckErrorAndLog("glTextureParameteri", name);
5807 gl.getTextureParameteriv(texture, name, &value_dst);
5808 is_ok &= CheckErrorAndLog("glGetTextureParameteriv", name);
5810 is_ok &= CompareAndLog(value_src, value_dst, name);
5814 glw::GLenum name = GL_TEXTURE_MIN_LOD;
5815 glw::GLint value_src = -100;
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_MAX_LOD;
5829 glw::GLint value_src = 100;
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_MAX_LEVEL;
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_SWIZZLE_R;
5857 glw::GLint value_src = GL_BLUE;
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_SWIZZLE_G;
5871 glw::GLint value_src = GL_ALPHA;
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_B;
5885 glw::GLint value_src = GL_RED;
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_A;
5899 glw::GLint value_src = GL_GREEN;
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_RGBA;
5913 glw::GLint value_src[4] = { GL_ZERO, GL_ONE, GL_ZERO, GL_ONE };
5914 glw::GLint value_dst[4] = {};
5916 gl.textureParameteriv(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_WRAP_S;
5927 glw::GLint value_src = GL_MIRROR_CLAMP_TO_EDGE;
5928 glw::GLint value_dst = 11;
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_WRAP_T;
5941 glw::GLint value_src = GL_CLAMP_TO_EDGE;
5942 glw::GLint value_dst = 11;
5944 gl.textureParameteri(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_R;
5955 glw::GLint value_src = GL_CLAMP_TO_EDGE;
5956 glw::GLint value_dst = 11;
5958 gl.textureParameteriv(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);
5976 gl.deleteTextures(1, &texture);
5979 while (GL_NO_ERROR != gl.getError())
5982 /* Result's setup. */
5985 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
5991 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
5995 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
6002 /** @brief Check for errors and log.
6004 * @param [in] fname Name of the function (to be logged).
6005 * @param [in] pname Parameter name with which function was called.
6007 * @return True if no error, false otherwise.
6009 bool GetSetParameterTest::CheckErrorAndLog(const glw::GLchar* fname, glw::GLenum pname)
6011 /* Shortcut for GL functionality. */
6012 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
6017 if (GL_NO_ERROR != (error = gl.getError()))
6019 m_context.getTestContext().getLog() << tcu::TestLog::Message << fname << " unexpectedly generated error "
6020 << glu::getErrorStr(error) << " during test of pname "
6021 << glu::getTextureParameterStr(pname) << ". Test fails."
6022 << tcu::TestLog::EndMessage;
6030 /** @brief Compare queried value of parameter with the expected vale.
6032 * @param [in] value_src First value.
6033 * @param [in] value_dst Second value.
6034 * @param [in] pname Parameter name.
6036 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6038 bool GetSetParameterTest::CompareAndLog(glw::GLint value_src, glw::GLint value_dst, glw::GLenum pname)
6040 if (value_src != value_dst)
6042 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Queried value of pname "
6043 << glu::getTextureParameterStr(pname) << " is equal to " << value_dst
6044 << ", however " << value_src << " was expected. Test fails."
6045 << tcu::TestLog::EndMessage;
6053 /** @brief Compare queried value of parameter with the expected vale.
6055 * @param [in] value_src First value.
6056 * @param [in] value_dst Second value.
6057 * @param [in] pname Parameter name.
6059 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6061 bool GetSetParameterTest::CompareAndLog(glw::GLuint value_src, glw::GLuint value_dst, glw::GLenum pname)
6063 if (value_src != value_dst)
6065 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Queried value of pname "
6066 << glu::getTextureParameterStr(pname) << " is equal to " << value_dst
6067 << ", however " << value_src << " was expected. Test fails."
6068 << tcu::TestLog::EndMessage;
6076 /** @brief Compare queried value of parameter with the expected vale.
6078 * @param [in] value_src First value.
6079 * @param [in] value_dst Second value.
6080 * @param [in] pname Parameter name.
6082 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6084 bool GetSetParameterTest::CompareAndLog(glw::GLfloat value_src, glw::GLfloat value_dst, glw::GLenum pname)
6086 if (de::abs(value_src - value_dst) > 0.0125 /* Precision */)
6088 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Queried value of pname "
6089 << glu::getTextureParameterStr(pname) << " is equal to " << value_dst
6090 << ", however " << value_src << " was expected. Test fails."
6091 << tcu::TestLog::EndMessage;
6099 /** @brief Compare queried value of parameter with the expected vale.
6101 * @param [in] value_src First value.
6102 * @param [in] value_dst Second value.
6103 * @param [in] pname Parameter name.
6105 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6107 bool GetSetParameterTest::CompareAndLog(glw::GLint value_src[4], glw::GLint value_dst[4], glw::GLenum pname)
6109 if ((value_src[0] != value_dst[0]) || (value_src[1] != value_dst[1]) || (value_src[2] != value_dst[2]) ||
6110 (value_src[3] != value_dst[3]))
6112 m_context.getTestContext().getLog()
6113 << tcu::TestLog::Message << "Queried value of pname " << glu::getTextureParameterStr(pname)
6114 << " is equal to [" << value_dst[0] << ", " << value_dst[1] << ", " << value_dst[2] << ", " << value_dst[3]
6115 << "], however " << value_src[0] << ", " << value_src[1] << ", " << value_src[2] << ", " << value_src[3]
6116 << "] was expected. Test fails." << tcu::TestLog::EndMessage;
6124 /** @brief Compare queried value of parameter with the expected vale.
6126 * @param [in] value_src First value.
6127 * @param [in] value_dst Second value.
6128 * @param [in] pname Parameter name.
6130 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6132 bool GetSetParameterTest::CompareAndLog(glw::GLuint value_src[4], glw::GLuint value_dst[4], glw::GLenum pname)
6134 if ((value_src[0] != value_dst[0]) || (value_src[1] != value_dst[1]) || (value_src[2] != value_dst[2]) ||
6135 (value_src[3] != value_dst[3]))
6137 m_context.getTestContext().getLog()
6138 << tcu::TestLog::Message << "Queried value of pname " << glu::getTextureParameterStr(pname)
6139 << " is equal to [" << value_dst[0] << ", " << value_dst[1] << ", " << value_dst[2] << ", " << value_dst[3]
6140 << "], however " << value_src[0] << ", " << value_src[1] << ", " << value_src[2] << ", " << value_src[3]
6141 << "] was expected. Test fails." << tcu::TestLog::EndMessage;
6149 /** @brief Compare queried value of parameter with the expected vale.
6151 * @param [in] value_src First value.
6152 * @param [in] value_dst Second value.
6153 * @param [in] pname Parameter name.
6155 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6157 bool GetSetParameterTest::CompareAndLog(glw::GLfloat value_src[4], glw::GLfloat value_dst[4], glw::GLenum pname)
6159 if ((de::abs(value_src[0] - value_dst[0]) > 0.0125 /* Precision */) ||
6160 (de::abs(value_src[1] - value_dst[1]) > 0.0125 /* Precision */) ||
6161 (de::abs(value_src[2] - value_dst[2]) > 0.0125 /* Precision */) ||
6162 (de::abs(value_src[3] - value_dst[3]) > 0.0125 /* Precision */))
6164 m_context.getTestContext().getLog()
6165 << tcu::TestLog::Message << "Queried value of pname " << glu::getTextureParameterStr(pname)
6166 << " is equal to [" << value_dst[0] << ", " << value_dst[1] << ", " << value_dst[2] << ", " << value_dst[3]
6167 << "], however " << value_src[0] << ", " << value_src[1] << ", " << value_src[2] << ", " << value_src[3]
6168 << "] was expected. Test fails." << tcu::TestLog::EndMessage;
6176 /******************************** Defaults Test Implementation ********************************/
6178 /** @brief Defaults Test constructor.
6180 * @param [in] context OpenGL context.
6182 DefaultsTest::DefaultsTest(deqp::Context& context)
6183 : deqp::TestCase(context, "textures_defaults", "Texture Defaults Test")
6185 /* Intentionally left blank. */
6188 /** @brief Defaults Test cases.
6190 * @return Iteration result.
6192 tcu::TestNode::IterateResult DefaultsTest::iterate()
6194 /* Shortcut for GL functionality. */
6195 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
6197 /* Get context setup. */
6198 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
6199 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
6201 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
6203 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
6208 /* Running tests. */
6210 bool is_error = false;
6213 glw::GLuint texture = 0;
6217 gl.createTextures(GL_TEXTURE_3D, 1, &texture);
6218 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
6221 glw::GLenum name = GL_DEPTH_STENCIL_TEXTURE_MODE;
6222 glw::GLint value_ref = GL_DEPTH_COMPONENT;
6223 glw::GLint value_dst = 0;
6225 gl.getTextureParameteriv(texture, name, &value_dst);
6226 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6228 is_ok &= CompareAndLog(value_ref, value_dst, name);
6232 glw::GLenum name = GL_TEXTURE_BASE_LEVEL;
6233 glw::GLint value_ref = 0;
6234 glw::GLint value_dst = 1;
6236 gl.getTextureParameteriv(texture, name, &value_dst);
6237 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6239 is_ok &= CompareAndLog(value_ref, value_dst, name);
6243 glw::GLenum name = GL_TEXTURE_BORDER_COLOR;
6244 glw::GLfloat value_ref[4] = { 0.f, 0.f, 0.f, 0.f };
6245 glw::GLfloat value_dst[4] = {};
6247 gl.getTextureParameterfv(texture, name, value_dst);
6248 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6250 is_ok &= CompareAndLog(value_ref, value_dst, name);
6254 glw::GLenum name = GL_TEXTURE_COMPARE_FUNC;
6255 glw::GLint value_ref = GL_LEQUAL;
6256 glw::GLint value_dst = 0;
6258 gl.getTextureParameteriv(texture, name, &value_dst);
6259 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6261 is_ok &= CompareAndLog(value_ref, value_dst, name);
6265 glw::GLenum name = GL_TEXTURE_COMPARE_MODE;
6266 glw::GLint value_ref = GL_NONE;
6267 glw::GLint value_dst = 0;
6269 gl.getTextureParameteriv(texture, name, &value_dst);
6270 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6272 is_ok &= CompareAndLog(value_ref, value_dst, name);
6276 glw::GLenum name = GL_TEXTURE_LOD_BIAS;
6277 glw::GLfloat value_ref = 0.f;
6278 glw::GLfloat value_dst = 0.f;
6280 gl.getTextureParameterfv(texture, name, &value_dst);
6281 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6283 is_ok &= CompareAndLog(value_ref, value_dst, name);
6287 glw::GLenum name = GL_TEXTURE_MIN_FILTER;
6288 glw::GLint value_ref = GL_NEAREST_MIPMAP_LINEAR;
6289 glw::GLint value_dst = 0;
6291 gl.getTextureParameteriv(texture, name, &value_dst);
6292 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6294 is_ok &= CompareAndLog(value_ref, value_dst, name);
6298 glw::GLenum name = GL_TEXTURE_MAG_FILTER;
6299 glw::GLint value_ref = GL_LINEAR;
6300 glw::GLint value_dst = 0;
6302 gl.getTextureParameteriv(texture, name, &value_dst);
6303 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6305 is_ok &= CompareAndLog(value_ref, value_dst, name);
6309 glw::GLenum name = GL_TEXTURE_MIN_LOD;
6310 glw::GLint value_ref = -1000;
6311 glw::GLint value_dst = 0;
6313 gl.getTextureParameteriv(texture, name, &value_dst);
6314 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6316 is_ok &= CompareAndLog(value_ref, value_dst, name);
6320 glw::GLenum name = GL_TEXTURE_MAX_LOD;
6321 glw::GLint value_ref = 1000;
6322 glw::GLint value_dst = 0;
6324 gl.getTextureParameteriv(texture, name, &value_dst);
6325 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6327 is_ok &= CompareAndLog(value_ref, value_dst, name);
6331 glw::GLenum name = GL_TEXTURE_MAX_LEVEL;
6332 glw::GLint value_ref = 1000;
6333 glw::GLint value_dst = 0;
6335 gl.getTextureParameteriv(texture, name, &value_dst);
6336 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6338 is_ok &= CompareAndLog(value_ref, value_dst, name);
6342 glw::GLenum name = GL_TEXTURE_SWIZZLE_R;
6343 glw::GLint value_ref = GL_RED;
6344 glw::GLint value_dst = 0;
6346 gl.getTextureParameteriv(texture, name, &value_dst);
6347 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6349 is_ok &= CompareAndLog(value_ref, value_dst, name);
6353 glw::GLenum name = GL_TEXTURE_SWIZZLE_G;
6354 glw::GLint value_ref = GL_GREEN;
6355 glw::GLint value_dst = 0;
6357 gl.getTextureParameteriv(texture, name, &value_dst);
6358 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6360 is_ok &= CompareAndLog(value_ref, value_dst, name);
6364 glw::GLenum name = GL_TEXTURE_SWIZZLE_B;
6365 glw::GLint value_ref = GL_BLUE;
6366 glw::GLint value_dst = 0;
6368 gl.getTextureParameteriv(texture, name, &value_dst);
6369 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6371 is_ok &= CompareAndLog(value_ref, value_dst, name);
6375 glw::GLenum name = GL_TEXTURE_SWIZZLE_A;
6376 glw::GLint value_ref = GL_ALPHA;
6377 glw::GLint value_dst = 0;
6379 gl.getTextureParameteriv(texture, name, &value_dst);
6380 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6382 is_ok &= CompareAndLog(value_ref, value_dst, name);
6386 glw::GLenum name = GL_TEXTURE_WRAP_S;
6387 glw::GLint value_ref = GL_REPEAT;
6388 glw::GLint value_dst = 11;
6390 gl.getTextureParameteriv(texture, name, &value_dst);
6391 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6393 is_ok &= CompareAndLog(value_ref, value_dst, name);
6397 glw::GLenum name = GL_TEXTURE_WRAP_T;
6398 glw::GLint value_ref = GL_REPEAT;
6399 glw::GLint value_dst = 11;
6401 gl.getTextureParameteriv(texture, name, &value_dst);
6402 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6404 is_ok &= CompareAndLog(value_ref, value_dst, name);
6408 glw::GLenum name = GL_TEXTURE_WRAP_R;
6409 glw::GLint value_ref = GL_REPEAT;
6410 glw::GLint value_dst = 11;
6412 gl.getTextureParameteriv(texture, name, &value_dst);
6413 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTextureParameter has failed");
6415 is_ok &= CompareAndLog(value_ref, value_dst, name);
6427 gl.deleteTextures(1, &texture);
6430 while (GL_NO_ERROR != gl.getError())
6433 /* Result's setup. */
6436 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
6442 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
6446 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
6453 /** @brief Compare queried value of parameter with the expected vale.
6455 * @param [in] value_src First value.
6456 * @param [in] value_dst Second value.
6457 * @param [in] pname Parameter name.
6459 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6461 bool DefaultsTest::CompareAndLog(glw::GLint value_ref, glw::GLint value_dst, glw::GLenum pname)
6463 if (value_ref != value_dst)
6465 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Queried value of pname "
6466 << glu::getTextureParameterStr(pname) << " is equal to " << value_dst
6467 << ", however " << value_ref << " was expected. Test fails."
6468 << tcu::TestLog::EndMessage;
6476 /** @brief Compare queried value of parameter with the expected vale.
6478 * @param [in] value_src First value.
6479 * @param [in] value_dst Second value.
6480 * @param [in] pname Parameter name.
6482 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6484 bool DefaultsTest::CompareAndLog(glw::GLuint value_ref, glw::GLuint value_dst, glw::GLenum pname)
6486 if (value_ref != value_dst)
6488 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Queried value of pname "
6489 << glu::getTextureParameterStr(pname) << " is equal to " << value_dst
6490 << ", however " << value_ref << " was expected. Test fails."
6491 << tcu::TestLog::EndMessage;
6499 /** @brief Compare queried value of parameter with the expected vale.
6501 * @param [in] value_src First value.
6502 * @param [in] value_dst Second value.
6503 * @param [in] pname Parameter name.
6505 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6507 bool DefaultsTest::CompareAndLog(glw::GLfloat value_ref, glw::GLfloat value_dst, glw::GLenum pname)
6509 if (de::abs(value_ref - value_dst) > 0.0125 /* Precision */)
6511 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Queried value of pname "
6512 << glu::getTextureParameterStr(pname) << " is equal to " << value_dst
6513 << ", however " << value_ref << " was expected. Test fails."
6514 << tcu::TestLog::EndMessage;
6522 /** @brief Compare queried value of parameter with the expected vale.
6524 * @param [in] value_src First value.
6525 * @param [in] value_dst Second value.
6526 * @param [in] pname Parameter name.
6528 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6530 bool DefaultsTest::CompareAndLog(glw::GLint value_ref[4], glw::GLint value_dst[4], glw::GLenum pname)
6532 if ((value_ref[0] != value_dst[0]) || (value_ref[1] != value_dst[1]) || (value_ref[2] != value_dst[2]) ||
6533 (value_ref[3] != value_dst[3]))
6535 m_context.getTestContext().getLog()
6536 << tcu::TestLog::Message << "Queried value of pname " << glu::getTextureParameterStr(pname)
6537 << " is equal to [" << value_dst[0] << ", " << value_dst[1] << ", " << value_dst[2] << ", " << value_dst[3]
6538 << "], however " << value_ref[0] << ", " << value_ref[1] << ", " << value_ref[2] << ", " << value_ref[3]
6539 << "] was expected. Test fails." << tcu::TestLog::EndMessage;
6547 /** @brief Compare queried value of parameter with the expected vale.
6549 * @param [in] value_src First value.
6550 * @param [in] value_dst Second value.
6551 * @param [in] pname Parameter name.
6553 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6555 bool DefaultsTest::CompareAndLog(glw::GLuint value_ref[4], glw::GLuint value_dst[4], glw::GLenum pname)
6557 if ((value_ref[0] != value_dst[0]) || (value_ref[1] != value_dst[1]) || (value_ref[2] != value_dst[2]) ||
6558 (value_ref[3] != value_dst[3]))
6560 m_context.getTestContext().getLog()
6561 << tcu::TestLog::Message << "Queried value of pname " << glu::getTextureParameterStr(pname)
6562 << " is equal to [" << value_dst[0] << ", " << value_dst[1] << ", " << value_dst[2] << ", " << value_dst[3]
6563 << "], however " << value_ref[0] << ", " << value_ref[1] << ", " << value_ref[2] << ", " << value_ref[3]
6564 << "] was expected. Test fails." << tcu::TestLog::EndMessage;
6572 /** @brief Compare queried value of parameter with the expected vale.
6574 * @param [in] value_src First value.
6575 * @param [in] value_dst Second value.
6576 * @param [in] pname Parameter name.
6578 * @return True if no error was generated by CopyTextureSubImage*D, false otherwise
6580 bool DefaultsTest::CompareAndLog(glw::GLfloat value_ref[4], glw::GLfloat value_dst[4], glw::GLenum pname)
6582 if ((de::abs(value_ref[0] - value_dst[0]) > 0.0125 /* Precision */) ||
6583 (de::abs(value_ref[1] - value_dst[1]) > 0.0125 /* Precision */) ||
6584 (de::abs(value_ref[2] - value_dst[2]) > 0.0125 /* Precision */) ||
6585 (de::abs(value_ref[3] - value_dst[3]) > 0.0125 /* Precision */))
6587 m_context.getTestContext().getLog()
6588 << tcu::TestLog::Message << "Queried value of pname " << glu::getTextureParameterStr(pname)
6589 << " is equal to [" << value_dst[0] << ", " << value_dst[1] << ", " << value_dst[2] << ", " << value_dst[3]
6590 << "], however " << value_ref[0] << ", " << value_ref[1] << ", " << value_ref[2] << ", " << value_ref[3]
6591 << "] was expected. Test fails." << tcu::TestLog::EndMessage;
6599 /******************************** Generate Mipmap Test Implementation ********************************/
6601 /** @brief Generate Mipmap Test constructor.
6603 * @param [in] context OpenGL context.
6605 GenerateMipmapTest::GenerateMipmapTest(deqp::Context& context)
6606 : deqp::TestCase(context, "textures_generate_mipmaps", "Textures Generate Mipmap Test")
6608 /* Intentionally left blank. */
6611 /** @brief Generate Mipmap Test cases.
6613 * @return Iteration result.
6615 tcu::TestNode::IterateResult GenerateMipmapTest::iterate()
6617 /* Shortcut for GL functionality. */
6618 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
6620 /* Get context setup. */
6621 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
6622 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
6624 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
6626 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
6631 /* Running tests. */
6633 bool is_error = false;
6635 /* Texture and cpu results storage. */
6636 glw::GLuint texture = 0;
6637 glw::GLubyte* result = DE_NULL;
6641 /* Prepare texture. */
6642 gl.genTextures(1, &texture);
6643 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
6645 gl.bindTexture(GL_TEXTURE_1D, texture);
6646 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
6648 gl.texImage1D(GL_TEXTURE_1D, 0, GL_R8, s_texture_width, 0, GL_RED, GL_UNSIGNED_BYTE, s_texture_data);
6649 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
6651 /* Generate mipmaps with tested function. */
6652 gl.generateTextureMipmap(texture);
6654 glw::GLenum error = GL_NO_ERROR;
6656 if (GL_NO_ERROR != (error = gl.getError()))
6658 m_context.getTestContext().getLog()
6659 << tcu::TestLog::Message << "GenerateTextureMipmap unexpectedly generated error "
6660 << glu::getErrorStr(error) << ". Test fails." << tcu::TestLog::EndMessage;
6665 /* Continue only if mipmaps has been generated. */
6668 result = new glw::GLubyte[s_texture_width];
6670 if (DE_NULL == result)
6675 /* For each mipmap. */
6676 for (glw::GLuint i = 0, j = s_texture_width;
6677 i < s_texture_width_log - 1 /* Do not test single pixel mipmap. */; ++i, j /= 2)
6679 /* Check mipmap size. */
6680 glw::GLint mipmap_size = 0;
6682 gl.getTexLevelParameteriv(GL_TEXTURE_1D, i, GL_TEXTURE_WIDTH, &mipmap_size);
6683 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
6685 if (mipmap_size != (glw::GLint)j)
6687 m_context.getTestContext().getLog()
6688 << tcu::TestLog::Message
6689 << "GenerateTextureMipmap unexpectedly generated mipmap with improper size. Mipmap size is "
6690 << mipmap_size << ", but " << j << " was expected. Test fails." << tcu::TestLog::EndMessage;
6698 gl.getTexImage(GL_TEXTURE_1D, i, GL_RED, GL_UNSIGNED_BYTE, result);
6699 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexImage has failed");
6701 /* Make comparison. */
6702 for (glw::GLuint k = 0; k < j - 1; ++k)
6704 if (((glw::GLint)result[k + 1]) - ((glw::GLint)result[k]) < 0)
6706 m_context.getTestContext().getLog() << tcu::TestLog::Message
6707 << "GenerateTextureMipmap unexpectedly generated improper "
6708 "mipmap (not descending). Test fails."
6709 << tcu::TestLog::EndMessage;
6728 gl.deleteTextures(1, &texture);
6731 if (DE_NULL != result)
6736 while (GL_NO_ERROR != gl.getError())
6739 /* Result's setup. */
6742 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
6748 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
6752 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
6759 /** Reference data. */
6760 const glw::GLubyte GenerateMipmapTest::s_texture_data[] = {
6761 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
6762 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
6763 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
6764 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
6765 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
6766 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131,
6767 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153,
6768 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
6769 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197,
6770 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
6771 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241,
6772 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
6775 /** Reference data parameters. */
6776 const glw::GLuint GenerateMipmapTest::s_texture_width = 256;
6777 const glw::GLuint GenerateMipmapTest::s_texture_width_log = 8;
6779 /******************************** Bind Unit Test Implementation ********************************/
6781 /** @brief Bind Unit Test constructor.
6783 * @param [in] context OpenGL context.
6785 BindUnitTest::BindUnitTest(deqp::Context& context)
6786 : deqp::TestCase(context, "textures_bind_unit", "Textures Bind Unit Test")
6799 /** @brief Bind Unit Test cases.
6801 * @return Iteration result.
6803 tcu::TestNode::IterateResult BindUnitTest::iterate()
6805 /* Get context setup. */
6806 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
6807 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
6809 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
6811 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
6816 /* Running tests. */
6818 bool is_error = false;
6825 CreateVertexArray();
6838 /* Result's setup. */
6841 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
6847 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
6851 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
6858 /** @brief Create test program.
6860 void BindUnitTest::CreateProgram()
6862 /* Shortcut for GL functionality */
6863 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
6867 glw::GLchar const* source;
6868 glw::GLenum const type;
6870 } shader[] = { { s_vertex_shader, GL_VERTEX_SHADER, 0 }, { s_fragment_shader, GL_FRAGMENT_SHADER, 0 } };
6872 glw::GLuint const shader_count = sizeof(shader) / sizeof(shader[0]);
6876 /* Create program. */
6877 m_po = gl.createProgram();
6878 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateProgram call failed.");
6880 /* Shader compilation. */
6882 for (glw::GLuint i = 0; i < shader_count; ++i)
6884 if (DE_NULL != shader[i].source)
6886 shader[i].id = gl.createShader(shader[i].type);
6888 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateShader call failed.");
6890 gl.attachShader(m_po, shader[i].id);
6892 GLU_EXPECT_NO_ERROR(gl.getError(), "glAttachShader call failed.");
6894 gl.shaderSource(shader[i].id, 1, &shader[i].source, NULL);
6896 GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource call failed.");
6898 gl.compileShader(shader[i].id);
6900 GLU_EXPECT_NO_ERROR(gl.getError(), "glCompileShader call failed.");
6902 glw::GLint status = GL_FALSE;
6904 gl.getShaderiv(shader[i].id, GL_COMPILE_STATUS, &status);
6905 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv call failed.");
6907 if (GL_FALSE == status)
6909 glw::GLint log_size = 0;
6910 gl.getShaderiv(shader[i].id, GL_INFO_LOG_LENGTH, &log_size);
6911 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv call failed.");
6913 glw::GLchar* log_text = new glw::GLchar[log_size];
6915 gl.getShaderInfoLog(shader[i].id, log_size, NULL, &log_text[0]);
6917 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Shader compilation has failed.\n"
6918 << "Shader type: " << glu::getShaderTypeStr(shader[i].type)
6920 << "Shader compilation error log:\n"
6922 << "Shader source code:\n"
6923 << shader[i].source << "\n"
6924 << tcu::TestLog::EndMessage;
6928 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderInfoLog call failed.");
6936 gl.linkProgram(m_po);
6938 GLU_EXPECT_NO_ERROR(gl.getError(), "glTransformFeedbackVaryings call failed.");
6940 glw::GLint status = GL_FALSE;
6942 gl.getProgramiv(m_po, GL_LINK_STATUS, &status);
6944 if (GL_TRUE == status)
6946 for (glw::GLuint i = 0; i < shader_count; ++i)
6950 gl.detachShader(m_po, shader[i].id);
6952 GLU_EXPECT_NO_ERROR(gl.getError(), "glDetachShader call failed.");
6958 glw::GLint log_size = 0;
6960 gl.getProgramiv(m_po, GL_INFO_LOG_LENGTH, &log_size);
6962 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramiv call failed.");
6964 glw::GLchar* log_text = new glw::GLchar[log_size];
6966 gl.getProgramInfoLog(m_po, log_size, NULL, &log_text[0]);
6968 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Program linkage has failed due to:\n"
6970 << tcu::TestLog::EndMessage;
6974 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramInfoLog call failed.");
6983 gl.deleteProgram(m_po);
6989 for (glw::GLuint i = 0; i < shader_count; ++i)
6991 if (0 != shader[i].id)
6993 gl.deleteShader(shader[i].id);
7005 /** @brief Create texture.
7007 void BindUnitTest::CreateTextures()
7009 /* Shortcut for GL functionality. */
7010 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7012 /* Prepare texture. */
7013 gl.genTextures(4, m_to);
7014 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
7016 /* Setup pixel sotre modes.*/
7017 gl.pixelStorei(GL_UNPACK_ALIGNMENT, sizeof(glw::GLubyte));
7018 GLU_EXPECT_NO_ERROR(gl.getError(), "glPixelStorei has failed");
7020 gl.pixelStorei(GL_PACK_ALIGNMENT, sizeof(glw::GLubyte));
7021 GLU_EXPECT_NO_ERROR(gl.getError(), "glPixelStorei has failed");
7024 gl.bindTexture(GL_TEXTURE_2D, m_to[0]);
7025 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
7027 gl.texImage2D(GL_TEXTURE_2D, 0, GL_R8, s_texture_width, s_texture_height, 0, GL_RED, GL_UNSIGNED_BYTE,
7029 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
7031 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
7032 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
7033 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri call failed.");
7035 /* Green texture. */
7036 gl.bindTexture(GL_TEXTURE_2D, m_to[1]);
7037 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
7039 gl.texImage2D(GL_TEXTURE_2D, 0, GL_R8, s_texture_width, s_texture_height, 0, GL_RED, GL_UNSIGNED_BYTE,
7041 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
7043 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
7044 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
7045 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri call failed.");
7048 gl.bindTexture(GL_TEXTURE_2D, m_to[2]);
7049 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
7051 gl.texImage2D(GL_TEXTURE_2D, 0, GL_R8, s_texture_width, s_texture_height, 0, GL_RED, GL_UNSIGNED_BYTE,
7053 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
7055 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
7056 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
7057 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri call failed.");
7059 /* Alpha texture. */
7060 gl.bindTexture(GL_TEXTURE_2D, m_to[3]);
7061 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
7063 gl.texImage2D(GL_TEXTURE_2D, 0, GL_R8, s_texture_width, s_texture_height, 0, GL_RED, GL_UNSIGNED_BYTE,
7065 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
7067 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
7068 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
7069 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri call failed.");
7072 /** @brief Create framebuffer.
7074 void BindUnitTest::CreateFrambuffer()
7076 /* Shortcut for GL functionality. */
7077 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7079 /* Prepare framebuffer. */
7080 gl.genFramebuffers(1, &m_fbo);
7081 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
7083 gl.genRenderbuffers(1, &m_rbo);
7084 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
7086 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
7087 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
7089 gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo);
7090 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
7092 gl.renderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, s_texture_width, s_texture_height);
7093 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage call failed.");
7095 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo);
7096 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer call failed.");
7098 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
7103 gl.viewport(0, 0, s_texture_width, s_texture_height);
7104 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
7106 /* Clear framebuffer's content. */
7107 gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
7108 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor call failed.");
7110 gl.clear(GL_COLOR_BUFFER_BIT);
7111 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear call failed.");
7114 /** @brief Create vertex array object.
7116 void BindUnitTest::CreateVertexArray()
7118 /* Shortcut for GL functionality. */
7119 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7121 gl.genVertexArrays(1, &m_vao);
7122 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays call has failed.");
7124 gl.bindVertexArray(m_vao);
7125 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray call has failed.");
7128 bool BindUnitTest::Draw()
7130 /* Shortcut for GL functionality. */
7131 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7133 /* Setup program. */
7134 gl.useProgram(m_po);
7135 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram call has failed.");
7137 /* Bind textures to proper units and setup program's samplers. */
7138 for (glw::GLuint i = 0; i < 4; ++i)
7140 /* Tested binding funcion. */
7141 gl.bindTextureUnit(i, m_to[i]);
7143 /* Check for errors. */
7144 glw::GLenum error = GL_NO_ERROR;
7146 if (GL_NO_ERROR != (error = gl.getError()))
7148 m_context.getTestContext().getLog()
7149 << tcu::TestLog::Message << "BindTextureUnit unexpectedly generated error " << glu::getErrorStr(error)
7150 << " when binding texture " << m_to[i] << " to texture unit " << i << ". Test fails."
7151 << tcu::TestLog::EndMessage;
7156 /* Sampler setup. */
7157 gl.uniform1i(gl.getUniformLocation(m_po, s_fragment_shader_samplers[i]), i);
7158 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation or glUniform1i call has failed.");
7162 gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
7163 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays call has failed.");
7168 /** @brief Compare results with reference.
7170 * @return True if equal, false otherwise.
7172 bool BindUnitTest::Check()
7174 /* Shortcut for GL functionality. */
7175 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7177 /* Setup storage for results. */
7178 m_result = new glw::GLubyte[s_texture_count_rgba];
7180 /* Setup pixel sotre modes.*/
7181 gl.pixelStorei(GL_UNPACK_ALIGNMENT, sizeof(glw::GLubyte));
7182 GLU_EXPECT_NO_ERROR(gl.getError(), "glPixelStorei has failed");
7184 gl.pixelStorei(GL_PACK_ALIGNMENT, sizeof(glw::GLubyte));
7185 GLU_EXPECT_NO_ERROR(gl.getError(), "glPixelStorei has failed");
7187 /* Query framebuffer's image. */
7188 gl.readPixels(0, 0, s_texture_width, s_texture_height, GL_RGBA, GL_UNSIGNED_BYTE, m_result);
7189 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays call has failed.");
7191 /* Compare values with reference. */
7192 for (glw::GLuint i = 0; i < s_texture_count_rgba; ++i)
7194 if (s_texture_data_rgba[i] != m_result[i])
7196 m_context.getTestContext().getLog()
7197 << tcu::TestLog::Message << "Framebuffer data " << DataToString(s_texture_count_rgba, m_result)
7198 << " does not match the reference values " << DataToString(s_texture_count_rgba, s_texture_data_rgba)
7199 << "." << tcu::TestLog::EndMessage;
7208 /** @brief Clean GL objects, test variables and GL errors.
7210 void BindUnitTest::CleanAll()
7212 /* Shortcut for GL functionality. */
7213 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7215 /* Release GL objects. */
7220 gl.deleteProgram(m_po);
7225 if (m_to[0] || m_to[1] || m_to[2] || m_to[3])
7227 gl.deleteTextures(4, m_to);
7237 gl.deleteFramebuffers(1, &m_fbo);
7244 gl.deleteRenderbuffers(1, &m_rbo);
7250 if (DE_NULL != m_result)
7255 /* Erros clean-up. */
7256 while (GL_NO_ERROR != gl.getError())
7260 /** @brief Convert raw data into string for logging purposes.
7262 * @param [in] count Count of the data.
7263 * @param [in] data Raw data.
7265 * @return String representation of data.
7267 std::string BindUnitTest::DataToString(glw::GLuint count, const glw::GLubyte data[])
7269 std::string data_str = "[";
7271 for (glw::GLuint i = 0; i < count; ++i)
7273 std::stringstream int_sstream;
7275 int_sstream << unsigned(data[i]);
7277 data_str.append(int_sstream.str());
7281 data_str.append(", ");
7285 data_str.append("]");
7292 /** Reference data and parameters. */
7293 const glw::GLubyte BindUnitTest::s_texture_data_r[] = { 0, 4, 8, 12, 16, 20 };
7294 const glw::GLubyte BindUnitTest::s_texture_data_g[] = { 1, 5, 9, 13, 17, 21 };
7295 const glw::GLubyte BindUnitTest::s_texture_data_b[] = { 2, 6, 10, 14, 18, 22 };
7296 const glw::GLubyte BindUnitTest::s_texture_data_a[] = { 3, 7, 11, 15, 19, 23 };
7297 const glw::GLubyte BindUnitTest::s_texture_data_rgba[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
7298 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 };
7299 const glw::GLuint BindUnitTest::s_texture_width = 2;
7300 const glw::GLuint BindUnitTest::s_texture_height = 3;
7301 const glw::GLuint BindUnitTest::s_texture_count_rgba = sizeof(s_texture_data_rgba) / sizeof(s_texture_data_rgba[0]);
7303 /* Vertex shader source code. */
7304 const glw::GLchar* BindUnitTest::s_vertex_shader = "#version 450\n"
7308 " switch(gl_VertexID)\n"
7311 " gl_Position = vec4(-1.0, 1.0, 0.0, 1.0);\n"
7314 " gl_Position = vec4( 1.0, 1.0, 0.0, 1.0);\n"
7317 " gl_Position = vec4(-1.0,-1.0, 0.0, 1.0);\n"
7320 " gl_Position = vec4( 1.0,-1.0, 0.0, 1.0);\n"
7325 /* Fragment shader source program. */
7326 const glw::GLchar* BindUnitTest::s_fragment_shader =
7329 "layout(pixel_center_integer) in vec4 gl_FragCoord;\n"
7331 "uniform sampler2D texture_input_r;\n"
7332 "uniform sampler2D texture_input_g;\n"
7333 "uniform sampler2D texture_input_b;\n"
7334 "uniform sampler2D texture_input_a;\n"
7336 "out vec4 color_output;\n"
7340 " color_output = vec4(texelFetch(texture_input_r, ivec2(gl_FragCoord.xy), 0).r,\n"
7341 " texelFetch(texture_input_g, ivec2(gl_FragCoord.xy), 0).r,\n"
7342 " texelFetch(texture_input_b, ivec2(gl_FragCoord.xy), 0).r,\n"
7343 " texelFetch(texture_input_a, ivec2(gl_FragCoord.xy), 0).r);\n"
7346 const glw::GLchar* BindUnitTest::s_fragment_shader_samplers[4] = { "texture_input_r", "texture_input_g",
7347 "texture_input_b", "texture_input_a" };
7349 /******************************** Get Image Test Implementation ********************************/
7351 /** @brief Get Image Test constructor.
7353 * @param [in] context OpenGL context.
7355 GetImageTest::GetImageTest(deqp::Context& context)
7356 : deqp::TestCase(context, "textures_get_image", "Textures Get Image Test")
7358 /* Intentionally left blank */
7361 /** Reference data. */
7362 const glw::GLubyte GetImageTest::s_texture_data[] = { 0x0, 0x0, 0x0, 0xff, 0x7f, 0x7f, 0x7f, 0xff, 0xc3, 0xc3, 0xc3,
7363 0xff, 0xff, 0xff, 0xff, 0xff, 0x88, 0x0, 0x15, 0xff, 0xed, 0x1c,
7364 0x24, 0xff, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x0, 0xff, 0xc8,
7365 0xbf, 0xe7, 0xff, 0x70, 0x92, 0xbe, 0xff, 0x99, 0xd9, 0xea, 0xff,
7366 0xb5, 0xe6, 0x1d, 0xff, 0xa3, 0x49, 0xa4, 0xff, 0x3f, 0x48, 0xcc,
7367 0xff, 0x0, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0xff };
7369 /** Reference data (compressed). */
7370 const glw::GLubyte GetImageTest::s_texture_data_compressed[] = { 0xa6, 0x39, 0x9, 0xf1, 0x88, 0x8b, 0x75, 0x85 };
7372 /** Reference data parameters. */
7373 const glw::GLuint GetImageTest::s_texture_width = 4;
7374 const glw::GLuint GetImageTest::s_texture_height = 4;
7375 const glw::GLuint GetImageTest::s_texture_size = sizeof(s_texture_data);
7376 const glw::GLuint GetImageTest::s_texture_size_compressed = sizeof(s_texture_data_compressed);
7377 const glw::GLuint GetImageTest::s_texture_count = s_texture_size / sizeof(s_texture_data[0]);
7378 const glw::GLuint GetImageTest::s_texture_count_compressed =
7379 s_texture_size_compressed / sizeof(s_texture_data_compressed[0]);
7381 /** @brief Get Image Test cases.
7383 * @return Iteration result.
7385 tcu::TestNode::IterateResult GetImageTest::iterate()
7387 /* Shortcut for GL functionality. */
7388 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7390 /* Get context setup. */
7391 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
7392 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
7394 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
7396 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
7401 /* Running tests. */
7403 bool is_error = false;
7406 glw::GLuint texture = 0;
7407 glw::GLubyte result[s_texture_count] = {};
7408 glw::GLubyte result_compressed[s_texture_count_compressed] = {};
7412 /* Uncompressed case. */
7414 /* Texture initiation. */
7415 gl.genTextures(1, &texture);
7416 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
7418 gl.bindTexture(GL_TEXTURE_2D, texture);
7419 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
7421 gl.texImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, s_texture_width, s_texture_height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
7423 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
7425 /* Quering image with tested function. */
7426 gl.getTextureImage(texture, 0, GL_RGBA, GL_UNSIGNED_BYTE, sizeof(result), result);
7428 /* Check for errors. */
7429 glw::GLenum error = GL_NO_ERROR;
7431 if (GL_NO_ERROR != (error = gl.getError()))
7433 m_context.getTestContext().getLog()
7434 << tcu::TestLog::Message << "GetTextureImage unexpectedly generated error "
7435 << glu::getErrorStr(error) << ". Test fails." << tcu::TestLog::EndMessage;
7441 /* No error, so compare images. */
7442 for (glw::GLuint i = 0; i < s_texture_count; ++i)
7444 if (s_texture_data[i] != result[i])
7446 m_context.getTestContext().getLog() << tcu::TestLog::Message << "GetTextureImage returned "
7447 << DataToString(s_texture_count, result) << ", but "
7448 << DataToString(s_texture_count, s_texture_data)
7449 << " was expected. Test fails." << tcu::TestLog::EndMessage;
7459 /* Clean up texture .*/
7460 gl.deleteTextures(1, &texture);
7461 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
7465 /* Compressed case. */
7467 /* Texture initiation. */
7468 gl.genTextures(1, &texture);
7469 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
7471 gl.bindTexture(GL_TEXTURE_2D, texture);
7472 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
7474 gl.compressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB8_ETC2, s_texture_width, s_texture_height, 0,
7475 s_texture_size_compressed, s_texture_data_compressed);
7476 GLU_EXPECT_NO_ERROR(gl.getError(), "glCompressedTexImage2D has failed");
7478 /* Quering image with tested function. */
7479 gl.getCompressedTextureImage(texture, 0, s_texture_count_compressed * sizeof(result_compressed[0]),
7482 /* Check for errors. */
7483 glw::GLenum error = GL_NO_ERROR;
7485 if (GL_NO_ERROR != (error = gl.getError()))
7487 m_context.getTestContext().getLog()
7488 << tcu::TestLog::Message << "GetCompressedTextureImage unexpectedly generated error "
7489 << glu::getErrorStr(error) << ". Test fails." << tcu::TestLog::EndMessage;
7495 /* No error, so compare images. */
7496 for (glw::GLuint i = 0; i < s_texture_count_compressed; ++i)
7498 if (s_texture_data_compressed[i] != result_compressed[i])
7500 m_context.getTestContext().getLog()
7501 << tcu::TestLog::Message << "GetCompressedTextureImage returned "
7502 << DataToString(s_texture_count_compressed, result_compressed) << ", but "
7503 << DataToString(s_texture_count_compressed, s_texture_data_compressed)
7504 << " was expected. Test fails." << tcu::TestLog::EndMessage;
7523 gl.deleteTextures(1, &texture);
7526 /* Result's setup. */
7529 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
7535 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
7539 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
7546 /** @brief Convert raw data into string for logging purposes.
7548 * @param [in] count Count of the data.
7549 * @param [in] data Raw data.
7551 * @return String representation of data.
7553 std::string GetImageTest::DataToString(glw::GLuint count, const glw::GLubyte data[])
7555 std::string data_str = "[";
7557 for (glw::GLuint i = 0; i < count; ++i)
7559 std::stringstream int_sstream;
7561 int_sstream << unsigned(data[i]);
7563 data_str.append(int_sstream.str());
7567 data_str.append(", ");
7571 data_str.append("]");
7578 /******************************** Get Level Parameter Test Implementation ********************************/
7580 /** @brief Get Level Parameter Test constructor.
7582 * @param [in] context OpenGL context.
7584 GetLevelParameterTest::GetLevelParameterTest(deqp::Context& context)
7585 : deqp::TestCase(context, "textures_get_level_parameter", "Textures Get Level Parameter Test")
7587 /* Intentionally left blank */
7590 /** Reference data. */
7591 const glw::GLubyte GetLevelParameterTest::s_texture_data[] = {
7592 0x0, 0x0, 0x0, 0xff, 0x7f, 0x7f, 0x7f, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff,
7593 0x88, 0x0, 0x15, 0xff, 0xed, 0x1c, 0x24, 0xff, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x0, 0xff,
7594 0xc8, 0xbf, 0xe7, 0xff, 0x70, 0x92, 0xbe, 0xff, 0x99, 0xd9, 0xea, 0xff, 0xb5, 0xe6, 0x1d, 0xff,
7595 0xa3, 0x49, 0xa4, 0xff, 0x3f, 0x48, 0xcc, 0xff, 0x0, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0xff,
7597 0x0, 0x0, 0x0, 0xff, 0x7f, 0x7f, 0x7f, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff,
7598 0x88, 0x0, 0x15, 0xff, 0xed, 0x1c, 0x24, 0xff, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x0, 0xff,
7599 0xc8, 0xbf, 0xe7, 0xff, 0x70, 0x92, 0xbe, 0xff, 0x99, 0xd9, 0xea, 0xff, 0xb5, 0xe6, 0x1d, 0xff,
7600 0xa3, 0x49, 0xa4, 0xff, 0x3f, 0x48, 0xcc, 0xff, 0x0, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0xff,
7602 0x0, 0x0, 0x0, 0xff, 0x7f, 0x7f, 0x7f, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff,
7603 0x88, 0x0, 0x15, 0xff, 0xed, 0x1c, 0x24, 0xff, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x0, 0xff,
7604 0xc8, 0xbf, 0xe7, 0xff, 0x70, 0x92, 0xbe, 0xff, 0x99, 0xd9, 0xea, 0xff, 0xb5, 0xe6, 0x1d, 0xff,
7605 0xa3, 0x49, 0xa4, 0xff, 0x3f, 0x48, 0xcc, 0xff, 0x0, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0xff,
7607 0x0, 0x0, 0x0, 0xff, 0x7f, 0x7f, 0x7f, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff,
7608 0x88, 0x0, 0x15, 0xff, 0xed, 0x1c, 0x24, 0xff, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x0, 0xff,
7609 0xc8, 0xbf, 0xe7, 0xff, 0x70, 0x92, 0xbe, 0xff, 0x99, 0xd9, 0xea, 0xff, 0xb5, 0xe6, 0x1d, 0xff,
7610 0xa3, 0x49, 0xa4, 0xff, 0x3f, 0x48, 0xcc, 0xff, 0x0, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0xff
7613 /** Reference data parameters. */
7614 const glw::GLuint GetLevelParameterTest::s_texture_width = 4;
7615 const glw::GLuint GetLevelParameterTest::s_texture_height = 4;
7616 const glw::GLuint GetLevelParameterTest::s_texture_depth = 4;
7618 /** @brief Get Level Parameter Test cases.
7620 * @return Iteration result.
7622 tcu::TestNode::IterateResult GetLevelParameterTest::iterate()
7624 /* Shortcut for GL functionality. */
7625 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7627 /* Get context setup. */
7628 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
7629 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
7631 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
7633 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
7638 /* Running tests. */
7640 bool is_error = false;
7643 glw::GLuint texture = 0;
7647 /* Texture initiation. */
7648 gl.genTextures(1, &texture);
7649 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
7651 gl.bindTexture(GL_TEXTURE_3D, texture);
7652 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
7654 gl.texImage3D(GL_TEXTURE_3D, 0, GL_RGBA8, s_texture_width, s_texture_height, s_texture_depth, 0, GL_RGBA,
7655 GL_UNSIGNED_BYTE, s_texture_data);
7656 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
7658 gl.texImage3D(GL_TEXTURE_3D, 1, GL_RGBA8, s_texture_width / 2, s_texture_height / 2, s_texture_depth / 2, 0,
7659 GL_RGBA, GL_UNSIGNED_BYTE, s_texture_data);
7660 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
7662 static const glw::GLenum pnames[] = {
7663 GL_TEXTURE_WIDTH, GL_TEXTURE_HEIGHT, GL_TEXTURE_DEPTH, GL_TEXTURE_INTERNAL_FORMAT,
7664 GL_TEXTURE_RED_TYPE, GL_TEXTURE_GREEN_TYPE, GL_TEXTURE_BLUE_TYPE, GL_TEXTURE_ALPHA_TYPE,
7665 GL_TEXTURE_DEPTH_TYPE, GL_TEXTURE_RED_SIZE, GL_TEXTURE_GREEN_SIZE, GL_TEXTURE_BLUE_SIZE,
7666 GL_TEXTURE_ALPHA_SIZE, GL_TEXTURE_DEPTH_SIZE, GL_TEXTURE_COMPRESSED
7668 static const glw::GLuint pnames_count = sizeof(pnames) / sizeof(pnames[0]);
7670 /* Test GetTextureLevelParameteriv. */
7671 for (glw::GLuint i = 0; i < 2 /* levels */; ++i)
7673 for (glw::GLuint j = 0; j < pnames_count; ++j)
7675 glw::GLint result_legacy = 0;
7676 glw::GLint result_dsa = 0;
7678 /* Quering reference value. */
7679 gl.getTexLevelParameteriv(GL_TEXTURE_3D, i, pnames[j], &result_legacy);
7680 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
7682 /* Quering using DSA function. */
7683 gl.getTextureLevelParameteriv(texture, i, pnames[j], &result_dsa);
7685 /* Check for errors. */
7686 glw::GLenum error = GL_NO_ERROR;
7688 if (GL_NO_ERROR != (error = gl.getError()))
7690 m_context.getTestContext().getLog()
7691 << tcu::TestLog::Message << "GetTextureLevelParameteriv unexpectedly generated error "
7692 << glu::getErrorStr(error) << ". Test fails." << tcu::TestLog::EndMessage;
7698 /* Compare values. */
7699 if (result_legacy != result_dsa)
7701 m_context.getTestContext().getLog()
7702 << tcu::TestLog::Message << "For parameter name "
7703 << glu::getTextureLevelParameterStr(pnames[j]) << " GetTextureLevelParameteriv returned "
7704 << result_dsa << ", but reference value (queried using GetTexLevelParameteriv) was "
7705 << result_legacy << ". Test fails." << tcu::TestLog::EndMessage;
7713 /* Test GetTextureLevelParameterfv. */
7714 for (glw::GLuint i = 0; i < 2 /* levels */; ++i)
7716 for (glw::GLuint j = 0; j < pnames_count; ++j)
7718 glw::GLfloat result_legacy = 0.f;
7719 glw::GLfloat result_dsa = 0.f;
7721 /* Quering reference value. */
7722 gl.getTexLevelParameterfv(GL_TEXTURE_3D, i, pnames[j], &result_legacy);
7723 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameterfv has failed");
7725 /* Quering using DSA function. */
7726 gl.getTextureLevelParameterfv(texture, i, pnames[j], &result_dsa);
7728 /* Check for errors. */
7729 glw::GLenum error = GL_NO_ERROR;
7731 if (GL_NO_ERROR != (error = gl.getError()))
7733 m_context.getTestContext().getLog()
7734 << tcu::TestLog::Message << "GetTextureLevelParameterfv unexpectedly generated error "
7735 << glu::getErrorStr(error) << ". Test fails." << tcu::TestLog::EndMessage;
7741 /* Compare values. */
7742 if (de::abs(result_legacy - result_dsa) > 0.125 /* Precision. */)
7744 m_context.getTestContext().getLog()
7745 << tcu::TestLog::Message << "For parameter name "
7746 << glu::getTextureLevelParameterStr(pnames[j]) << " GetTextureLevelParameterfv returned "
7747 << result_dsa << ", but reference value (queried using GetTexLevelParameterfv) was "
7748 << result_legacy << ". Test fails." << tcu::TestLog::EndMessage;
7765 gl.deleteTextures(1, &texture);
7768 while (GL_NO_ERROR != gl.getError())
7771 /* Result's setup. */
7774 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
7780 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
7784 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
7791 /*********************************** Errors Utility Class *****************************************************/
7793 /** @brief Check for errors and log.
7795 * @param [in] context Test's context.
7796 * @param [in] expected_error Expected error value.
7797 * @param [in] function_name Name of the function (to be logged).
7798 * @param [in] log Log message.
7800 * @return True if error is equal to expected, false otherwise.
7802 bool ErrorsUtilities::CheckErrorAndLog(deqp::Context& context, glw::GLuint expected_error,
7803 const glw::GLchar* function_name, const glw::GLchar* log)
7805 /* Shortcut for GL functionality. */
7806 const glw::Functions& gl = context.getRenderContext().getFunctions();
7809 glw::GLenum error = GL_NO_ERROR;
7811 if (expected_error != (error = gl.getError()))
7813 context.getTestContext().getLog() << tcu::TestLog::Message << function_name << " generated error "
7814 << glu::getErrorStr(error) << " but, " << glu::getErrorStr(expected_error)
7815 << " was expected if " << log << tcu::TestLog::EndMessage;
7823 /******************************** Creation Errors Test Implementation ********************************/
7825 /** @brief Creation Errors Test constructor.
7827 * @param [in] context OpenGL context.
7829 CreationErrorsTest::CreationErrorsTest(deqp::Context& context)
7830 : deqp::TestCase(context, "textures_creation_errors", "Texture Objects Creation Errors Test")
7832 /* Intentionally left blank. */
7835 /** @brief Iterate Creation Errors Test cases.
7837 * @return Iteration result.
7839 tcu::TestNode::IterateResult CreationErrorsTest::iterate()
7841 /* Shortcut for GL functionality. */
7842 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7844 /* Get context setup. */
7845 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
7846 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
7848 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
7850 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
7855 /* Running tests. */
7857 bool is_error = false;
7859 /* Textures' objects */
7860 glw::GLuint texture = 0;
7864 /* Not a target test. */
7865 gl.createTextures(NotATarget(), 1, &texture);
7866 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glCreateTextures",
7867 "target is not one of the allowable values.");
7871 gl.deleteTextures(1, &texture);
7876 /* Negative number of textures. */
7877 gl.createTextures(GL_TEXTURE_2D, -1, &texture);
7878 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCreateTextures", "n is negative.");
7889 gl.deleteTextures(1, &texture);
7892 /* Errors clean up. */
7893 while (gl.getError())
7896 /* Result's setup. */
7899 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
7905 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
7909 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
7916 /** @brief Function retruns enum which is not a texture target.
7918 glw::GLenum CreationErrorsTest::NotATarget()
7920 static const glw::GLenum texture_targets[] = { GL_TEXTURE_1D,
7923 GL_TEXTURE_1D_ARRAY,
7924 GL_TEXTURE_2D_ARRAY,
7925 GL_TEXTURE_RECTANGLE,
7926 GL_TEXTURE_CUBE_MAP,
7927 GL_TEXTURE_CUBE_MAP_ARRAY,
7929 GL_TEXTURE_2D_MULTISAMPLE,
7930 GL_TEXTURE_2D_MULTISAMPLE_ARRAY };
7932 glw::GLenum not_a_target = 0;
7933 bool is_target = true;
7941 for (glw::GLuint i = 0; i < sizeof(texture_targets) / sizeof(texture_targets[0]); ++i)
7943 if (texture_targets[i] == not_a_target)
7951 return not_a_target;
7954 /******************************** Texture Buffer Errors Test Implementation ********************************/
7956 /** @brief Texture Buffer Errors Test constructor.
7958 * @param [in] context OpenGL context.
7960 BufferErrorsTest::BufferErrorsTest(deqp::Context& context)
7961 : deqp::TestCase(context, "textures_buffer_errors", "Texture Buffer Errors Test")
7963 /* Intentionally left blank. */
7966 /** @brief Iterate Texture Buffer Errors Test cases.
7968 * @return Iteration result.
7970 tcu::TestNode::IterateResult BufferErrorsTest::iterate()
7972 /* Shortcut for GL functionality. */
7973 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7975 /* Get context setup. */
7976 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
7977 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
7979 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
7981 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
7986 /* Running tests. */
7988 bool is_error = false;
7990 /* Textures' objects */
7991 glw::GLuint texture_buffer = 0;
7992 glw::GLuint texture_1D = 0;
7993 glw::GLuint buffer = 0;
7995 static const glw::GLubyte data[4] = { 1, 2, 3, 4 };
7996 static const glw::GLuint data_size = sizeof(data);
8000 /* Auxiliary objects setup. */
8001 gl.createTextures(GL_TEXTURE_BUFFER, 1, &texture_buffer);
8002 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8004 gl.createTextures(GL_TEXTURE_1D, 1, &texture_1D);
8005 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8007 gl.createBuffers(1, &buffer);
8008 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateBuffers has failed");
8010 gl.namedBufferData(buffer, data_size, data, GL_STATIC_COPY);
8011 GLU_EXPECT_NO_ERROR(gl.getError(), "glNamedBufferData has failed");
8013 /* Check that INVALID_OPERATION is generated by glTextureBuffer if texture
8014 is not the name of an existing texture object. */
8016 glw::GLuint not_a_texture = 0;
8018 while (gl.isTexture(++not_a_texture))
8020 GLU_EXPECT_NO_ERROR(gl.getError(), "glIsTexture has failed");
8022 gl.textureBuffer(not_a_texture, GL_RGBA8, buffer);
8024 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureBuffer",
8025 "texture is not the name of an existing texture object.");
8028 /* Check that INVALID_ENUM is generated by glTextureBuffer if the effective
8029 target of texture is not TEXTURE_BUFFER. */
8031 gl.textureBuffer(texture_1D, GL_RGBA8, buffer);
8033 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureBuffer",
8034 "the effective target of texture is not TEXTURE_BUFFER.");
8037 /* Check that INVALID_ENUM is generated if internalformat is not one of the
8038 sized internal formats described above. */
8040 gl.textureBuffer(texture_buffer, GL_COMPRESSED_SIGNED_RED_RGTC1, buffer);
8042 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureBuffer",
8043 "internalformat is not one of the sized internal formats described above..");
8046 /* Check that INVALID_OPERATION is generated if buffer is not zero and is
8047 not the name of an existing buffer object. */
8049 glw::GLuint not_a_buffer = 0;
8051 while (gl.isBuffer(++not_a_buffer))
8053 GLU_EXPECT_NO_ERROR(gl.getError(), "glIsBuffer has failed");
8055 gl.textureBuffer(texture_buffer, GL_RGBA8, not_a_buffer);
8057 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureBuffer",
8058 "buffer is not zero and is not the name of an existing buffer object.");
8070 gl.deleteTextures(1, &texture_1D);
8075 gl.deleteTextures(1, &texture_buffer);
8080 gl.deleteBuffers(1, &buffer);
8083 /* Errors clean up. */
8084 while (gl.getError())
8087 /* Result's setup. */
8090 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
8096 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
8100 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
8107 /******************************** Texture Buffer Range Errors Test Implementation ********************************/
8109 /** @brief Texture Buffer Range Errors Test constructor.
8111 * @param [in] context OpenGL context.
8113 BufferRangeErrorsTest::BufferRangeErrorsTest(deqp::Context& context)
8114 : deqp::TestCase(context, "textures_buffer_range_errors", "Texture Buffer Range Errors Test")
8116 /* Intentionally left blank. */
8119 /** @brief Iterate Texture Buffer Range Errors Test cases.
8121 * @return Iteration result.
8123 tcu::TestNode::IterateResult BufferRangeErrorsTest::iterate()
8125 /* Shortcut for GL functionality. */
8126 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8128 /* Get context setup. */
8129 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
8130 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
8132 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
8134 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
8139 /* Running tests. */
8141 bool is_error = false;
8143 /* Textures' objects */
8144 glw::GLuint texture_buffer = 0;
8145 glw::GLuint texture_1D = 0;
8146 glw::GLuint buffer = 0;
8148 static const glw::GLubyte data[4] = { 1, 2, 3, 4 };
8149 static const glw::GLuint data_size = sizeof(data);
8153 /* Auxiliary objects setup. */
8154 gl.createTextures(GL_TEXTURE_BUFFER, 1, &texture_buffer);
8155 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8157 gl.createTextures(GL_TEXTURE_1D, 1, &texture_1D);
8158 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8160 gl.createBuffers(1, &buffer);
8161 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateBuffers has failed");
8163 gl.namedBufferData(buffer, data_size, data, GL_STATIC_COPY);
8164 GLU_EXPECT_NO_ERROR(gl.getError(), "glNamedBufferData has failed");
8166 /* Check that INVALID_OPERATION is generated by TextureBufferRange if
8167 texture is not the name of an existing texture object.*/
8169 glw::GLuint not_a_texture = 0;
8171 while (gl.isTexture(++not_a_texture))
8173 GLU_EXPECT_NO_ERROR(gl.getError(), "glIsTexture has failed");
8175 gl.textureBufferRange(not_a_texture, GL_RGBA8, buffer, 0, data_size);
8177 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureBufferRange",
8178 "texture is not the name of an existing texture object.");
8181 /* Check that INVALID_ENUM is generated by TextureBufferRange if the
8182 effective target of texture is not TEXTURE_BUFFER. */
8184 gl.textureBufferRange(texture_1D, GL_RGBA8, buffer, 0, data_size);
8186 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureBufferRange",
8187 "the effective target of texture is not TEXTURE_BUFFER.");
8190 /* Check that INVALID_ENUM is generated by TextureBufferRange if
8191 internalformat is not one of the sized internal formats described above. */
8193 gl.textureBufferRange(texture_buffer, GL_COMPRESSED_SIGNED_RED_RGTC1, buffer, 0, data_size);
8195 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureBufferRange",
8196 "internalformat is not one of the supported sized internal formats.");
8199 /* Check that INVALID_OPERATION is generated by TextureBufferRange if
8200 buffer is not zero and is not the name of an existing buffer object. */
8202 glw::GLuint not_a_buffer = 0;
8204 while (gl.isBuffer(++not_a_buffer))
8206 GLU_EXPECT_NO_ERROR(gl.getError(), "glIsBuffer has failed");
8208 gl.textureBufferRange(texture_buffer, GL_RGBA8, not_a_buffer, 0, data_size);
8210 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureBufferRange",
8211 "buffer is not zero and is not the name of an existing buffer object.");
8214 /* Check that INVALID_VALUE is generated by TextureBufferRange if offset
8215 is negative, if size is less than or equal to zero, or if offset + size
8216 is greater than the value of BUFFER_SIZE for buffer. */
8218 gl.textureBufferRange(texture_buffer, GL_RGBA8, buffer, -1, data_size);
8220 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureBufferRange", "offset is negative.");
8222 gl.textureBufferRange(texture_buffer, GL_RGBA8, buffer, 0, 0);
8224 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureBufferRange", "size is zero.");
8226 gl.textureBufferRange(texture_buffer, GL_RGBA8, buffer, 0, -1);
8228 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureBufferRange", "size is negative.");
8230 gl.textureBufferRange(texture_buffer, GL_RGBA8, buffer, 0, data_size * 16);
8232 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureBufferRange",
8233 "size is greater than the value of BUFFER_SIZE for buffer.");
8236 /* Check that INVALID_VALUE is generated by TextureBufferRange if offset is
8237 not an integer multiple of the value of TEXTURE_BUFFER_OFFSET_ALIGNMENT. */
8239 glw::GLint gl_texture_buffer_offset_alignment = 0;
8241 gl.getIntegerv(GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT, &gl_texture_buffer_offset_alignment);
8243 /* If alignmet is 1 we cannot do anything. Error situtation is impossible then. */
8244 if (gl_texture_buffer_offset_alignment > 1)
8246 gl.textureBufferRange(texture_buffer, GL_RGBA8, buffer, 1, data_size - 1);
8248 is_ok &= CheckErrorAndLog(
8249 m_context, GL_INVALID_VALUE, "glTextureBufferRange",
8250 "offset is not an integer multiple of the value of TEXTURE_BUFFER_OFFSET_ALIGNMENT.");
8263 gl.deleteTextures(1, &texture_1D);
8268 gl.deleteTextures(1, &texture_buffer);
8273 gl.deleteBuffers(1, &buffer);
8276 /* Errors clean up. */
8277 while (gl.getError())
8280 /* Result's setup. */
8283 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
8289 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
8293 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
8300 /******************************** Texture Storage Errors Test Implementation ********************************/
8302 /** @brief Texture Storage Errors Test constructor.
8304 * @param [in] context OpenGL context.
8306 StorageErrorsTest::StorageErrorsTest(deqp::Context& context)
8307 : deqp::TestCase(context, "textures_storage_errors", "Texture Storage Errors Test")
8314 , m_to_2D_ms_immutable(0)
8316 , m_to_3D_ms_immutable(0)
8318 , m_internalformat_invalid(0)
8319 , m_max_texture_size(1)
8321 , m_max_array_texture_layers(1)
8323 /* Intentionally left blank. */
8326 /** @brief Iterate Texture Storage Errors Test cases.
8328 * @return Iteration result.
8330 tcu::TestNode::IterateResult StorageErrorsTest::iterate()
8332 /* Get context setup. */
8333 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
8334 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
8336 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
8338 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
8343 /* Running tests. */
8345 bool is_error = false;
8354 is_ok &= Test2DMultisample();
8355 is_ok &= Test3DMultisample();
8366 /* Result's setup. */
8369 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
8375 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
8379 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
8386 /** @brief Prepare test objects.
8388 void StorageErrorsTest::Prepare()
8390 /* Shortcut for GL functionality. */
8391 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8393 /* Auxiliary objects setup. */
8396 gl.createTextures(GL_TEXTURE_1D, 1, &m_to_1D);
8397 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8400 gl.createTextures(GL_TEXTURE_1D_ARRAY, 1, &m_to_1D_array);
8401 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8404 gl.createTextures(GL_TEXTURE_2D, 1, &m_to_2D);
8405 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8408 gl.createTextures(GL_TEXTURE_2D_ARRAY, 1, &m_to_2D_array);
8409 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8412 gl.createTextures(GL_TEXTURE_3D, 1, &m_to_3D);
8413 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8415 /* 2D Multisample */
8416 gl.createTextures(GL_TEXTURE_2D_MULTISAMPLE, 1, &m_to_2D_ms);
8417 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8419 /* 2D Multisample with storage */
8420 gl.createTextures(GL_TEXTURE_2D_MULTISAMPLE, 1, &m_to_2D_ms_immutable);
8421 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8423 gl.textureStorage2DMultisample(m_to_2D_ms_immutable, 1, GL_R8, 16, 16, false);
8424 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage2DMultisample has failed");
8426 /* 3D Multisample */
8427 gl.createTextures(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, 1, &m_to_3D_ms);
8428 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8430 /* 3D Multisample with storage */
8431 gl.createTextures(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, 1, &m_to_3D_ms_immutable);
8432 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
8434 gl.textureStorage3DMultisample(m_to_3D_ms_immutable, 1, GL_R8, 16, 16, 16, false);
8435 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage2DMultisample has failed");
8437 /* Invalid values */
8439 /* invalid texture object */
8440 while (gl.isTexture(++m_to_invalid))
8442 GLU_EXPECT_NO_ERROR(gl.getError(), "glIsTexture has failed");
8444 /* invalid internal format */
8445 static const glw::GLenum all_internal_formats[] = { GL_R8,
8514 GL_COMPRESSED_SRGB_ALPHA,
8515 GL_COMPRESSED_RED_RGTC1,
8516 GL_COMPRESSED_SIGNED_RED_RGTC1,
8517 GL_COMPRESSED_RG_RGTC2,
8518 GL_COMPRESSED_SIGNED_RG_RGTC2,
8519 GL_COMPRESSED_RGBA_BPTC_UNORM,
8520 GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM,
8521 GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT,
8522 GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT,
8523 GL_COMPRESSED_RGB8_ETC2,
8524 GL_COMPRESSED_SRGB8_ETC2,
8525 GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
8526 GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
8527 GL_COMPRESSED_RGBA8_ETC2_EAC,
8528 GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
8529 GL_COMPRESSED_R11_EAC,
8530 GL_COMPRESSED_SIGNED_R11_EAC,
8531 GL_COMPRESSED_RG11_EAC,
8532 GL_COMPRESSED_SIGNED_RG11_EAC,
8533 GL_DEPTH_COMPONENT16,
8534 GL_DEPTH_COMPONENT24,
8535 GL_DEPTH_COMPONENT32,
8536 GL_DEPTH_COMPONENT32F,
8537 GL_DEPTH24_STENCIL8,
8538 GL_DEPTH32F_STENCIL8,
8542 GL_STENCIL_INDEX16 };
8544 static const glw::GLuint all_internal_formats_count =
8545 sizeof(all_internal_formats) / sizeof(all_internal_formats[0]);
8547 bool is_valid = true;
8548 m_internalformat_invalid = 0;
8553 m_internalformat_invalid++;
8554 for (glw::GLuint i = 0; i < all_internal_formats_count; ++i)
8556 if (all_internal_formats[i] == m_internalformat_invalid)
8564 /* Maximum texture size.*/
8565 gl.getIntegerv(GL_MAX_TEXTURE_SIZE, &m_max_texture_size);
8566 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
8568 /* Maximum number of samples. */
8569 gl.getIntegerv(GL_MAX_SAMPLES, &m_max_samples);
8570 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
8572 /* Maximum number of array texture layers. */
8573 gl.getIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &m_max_array_texture_layers);
8574 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
8577 /** @brief Test TextureStorage1D
8579 * @return Test result.
8581 bool StorageErrorsTest::Test1D()
8583 /* Shortcut for GL functionality. */
8584 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8589 /* Check that INVALID_OPERATION is generated by TextureStorage1D if texture
8590 is not the name of an existing texture object. */
8592 gl.textureStorage1D(m_to_invalid, 1, GL_R8, 8);
8593 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage1D",
8594 "texture is not the name of an existing texture object.");
8597 /* Check that INVALID_ENUM is generated by TextureStorage1D if
8598 internalformat is not a valid sized internal format. */
8600 gl.textureStorage1D(m_to_1D, 1, m_internalformat_invalid, 8);
8601 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureStorage1D",
8602 "internalformat is not a valid sized internal format.");
8605 /* Check that INVALID_ENUM is generated by TextureStorage1D if target or
8606 the effective target of texture is not one of the accepted targets
8609 gl.textureStorage1D(m_to_2D, 1, GL_R8, 8);
8610 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage1D",
8611 "the effective target of texture is not one of the accepted targets.");
8614 /* Check that INVALID_VALUE is generated by TextureStorage1D if width or
8615 levels are less than 1. */
8617 gl.textureStorage1D(m_to_1D, 0, GL_R8, 8);
8618 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage1D", "levels is less than 1.");
8620 gl.textureStorage1D(m_to_1D, 1, GL_R8, 0);
8621 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage1D", "width is less than 1.");
8624 /* Check that INVALID_OPERATION is generated by TextureStorage1D if levels
8625 is greater than log2(width)+1. */
8627 gl.textureStorage1D(m_to_1D, 8, GL_R8, 8);
8628 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage1D",
8629 "levels is greater than log2(width)+1.");
8635 /** @brief Test TextureStorage2D
8637 * @return Test result.
8639 bool StorageErrorsTest::Test2D()
8641 /* Shortcut for GL functionality. */
8642 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8647 /* Check that INVALID_OPERATION is generated by TextureStorage2D if
8648 texture is not the name of an existing texture object. */
8650 gl.textureStorage2D(m_to_invalid, 1, GL_R8, 8, 8);
8651 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage2D",
8652 "texture is not the name of an existing texture object.");
8655 /* Check that INVALID_ENUM is generated by TextureStorage2D if
8656 internalformat is not a valid sized internal format. */
8658 gl.textureStorage2D(m_to_2D, 1, m_internalformat_invalid, 8, 8);
8659 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureStorage2D",
8660 "internalformat is not a valid sized internal format.");
8663 /* Check that INVALID_ENUM is generated by TextureStorage2D if target or
8664 the effective target of texture is not one of the accepted targets
8667 gl.textureStorage2D(m_to_1D, 1, GL_R8, 8, 8);
8668 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage2D",
8669 "the effective target of texture is not one of the accepted targets.");
8672 /* Check that INVALID_VALUE is generated by TextureStorage2D if width,
8673 height or levels are less than 1. */
8675 gl.textureStorage2D(m_to_2D, 0, GL_R8, 8, 8);
8676 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage2D", "levels is less than 1.");
8678 gl.textureStorage2D(m_to_2D, 1, GL_R8, 0, 8);
8679 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage2D", "width is less than 1.");
8681 gl.textureStorage2D(m_to_2D, 1, GL_R8, 8, 0);
8682 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage2D", "height is less than 1.");
8685 /* Check that INVALID_OPERATION is generated by TextureStorage2D if target
8686 is TEXTURE_1D_ARRAY or PROXY_TEXTURE_1D_ARRAY and levels is greater than
8689 gl.textureStorage2D(m_to_1D_array, 8, GL_R8, 8, 8);
8690 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage2D",
8691 "target is TEXTURE_1D_ARRAY and levels is greater than log2(width)+1.");
8694 /* Check that INVALID_OPERATION is generated by TextureStorage2D if target
8695 is not TEXTURE_1D_ARRAY or PROXY_TEXTURE_1D_ARRAY and levels is greater
8696 than log2(max(width, height))+1. */
8698 gl.textureStorage2D(m_to_2D, 8, GL_R8, 8, 8);
8699 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage2D",
8700 "target is TEXTURE_2D and levels is greater than log2(max(width, height))+1.");
8706 /** @brief Test TextureStorage3D
8708 * @return Test result.
8710 bool StorageErrorsTest::Test3D()
8712 /* Shortcut for GL functionality. */
8713 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8718 /* Check that INVALID_OPERATION is generated by TextureStorage3D if texture
8719 is not the name of an existing texture object. */
8721 gl.textureStorage3D(m_to_invalid, 1, GL_R8, 8, 8, 8);
8722 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage3D",
8723 "texture is not the name of an existing texture object.");
8726 /* Check that INVALID_ENUM is generated by TextureStorage3D if
8727 internalformat is not a valid sized internal format. */
8729 gl.textureStorage3D(m_to_3D, 1, m_internalformat_invalid, 8, 8, 8);
8730 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureStorage3D",
8731 "internalformat is not a valid sized internal format.");
8734 /* Check that INVALID_ENUM is generated by TextureStorage3D if target or
8735 the effective target of texture is not one of the accepted targets
8738 gl.textureStorage3D(m_to_1D, 1, GL_R8, 8, 8, 8);
8739 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage3D",
8740 "the effective target of texture is not one of the accepted targets.");
8743 /* Check that INVALID_VALUE is generated by TextureStorage3D if width,
8744 height, depth or levels are less than 1. */
8746 gl.textureStorage3D(m_to_3D, 0, GL_R8, 8, 8, 8);
8747 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage3D", "levels is less than 1.");
8749 gl.textureStorage3D(m_to_3D, 1, GL_R8, 0, 8, 8);
8750 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage3D", "width is less than 1.");
8752 gl.textureStorage3D(m_to_3D, 1, GL_R8, 8, 0, 8);
8753 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage3D", "height is less than 1.");
8755 gl.textureStorage3D(m_to_3D, 1, GL_R8, 8, 8, 0);
8756 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage3D", "depth is less than 1.");
8759 /* Check that INVALID_OPERATION is generated by TextureStorage3D if target
8760 is TEXTURE_3D or PROXY_TEXTURE_3D and levels is greater than
8761 log2(max(width, height, depth))+1. */
8763 gl.textureStorage3D(m_to_3D, 8, GL_R8, 8, 8, 8);
8764 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage3D",
8765 "target is TEXTURE_3D and levels is greater than log2(max(width, height, depth))+1.");
8768 /* Check that INVALID_OPERATION is generated by TextureStorage3D if target
8769 is TEXTURE_2D_ARRAY, PROXY_TEXTURE_2D_ARRAY, TEXURE_CUBE_ARRAY,
8770 or PROXY_TEXTURE_CUBE_MAP_ARRAY and levels is greater than
8771 log2(max(width, height))+1. */
8773 gl.textureStorage3D(m_to_2D_array, 6, GL_R8, 8, 8, 256);
8774 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage3D",
8775 "target is TEXTURE_2D_ARRAY and levels is greater than log2(max(width, height))+1.");
8781 /** @brief Test TextureStorage2DMultisample
8783 * @return Test result.
8785 bool StorageErrorsTest::Test2DMultisample()
8787 /* Shortcut for GL functionality. */
8788 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8793 /* Check that INVALID_OPERATION is generated by TextureStorage2DMultisample
8794 if texture is not the name of an existing texture object. */
8796 gl.textureStorage2DMultisample(m_to_invalid, 1, GL_R8, 8, 8, false);
8797 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage2DMultisample",
8798 "texture is not the name of an existing texture object.");
8801 /* Check that INVALID_ENUM is generated by TextureStorage2DMultisample if
8802 internalformat is not a valid color-renderable, depth-renderable or
8803 stencil-renderable format. */
8805 gl.textureStorage2DMultisample(m_to_2D_ms, 1, m_internalformat_invalid, 8, 8, false);
8806 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureStorage2DMultisample",
8807 "internalformat is not a valid sized internal format.");
8810 /* Check that INVALID_OPERATION is generated by TextureStorage2DMultisample if
8811 target or the effective target of texture is not one of the accepted
8812 targets described above. */
8814 gl.textureStorage2DMultisample(m_to_1D, 1, GL_R8, 8, 8, false);
8815 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage2DMultisample",
8816 "the effective target of texture is not one of the accepted targets.");
8819 /* Check that INVALID_VALUE is generated by TextureStorage2DMultisample if
8820 width or height are less than 1 or greater than the value of
8821 MAX_TEXTURE_SIZE. */
8823 gl.textureStorage2DMultisample(m_to_2D_ms, 1, GL_R8, 0, 8, false);
8825 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage2DMultisample", "width is less than 1.");
8827 gl.textureStorage2DMultisample(m_to_2D_ms, 1, GL_R8, 8, 0, false);
8829 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage2DMultisample", "height is less than 1.");
8831 gl.textureStorage2DMultisample(m_to_2D_ms, 1, GL_R8, m_max_texture_size * 2, 8, false);
8832 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage2DMultisample",
8833 "width is greater than the value of MAX_TEXTURE_SIZE.");
8835 gl.textureStorage2DMultisample(m_to_2D_ms, 1, GL_R8, 8, m_max_texture_size * 2, false);
8836 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage2DMultisample",
8837 "height is greater than the value of MAX_TEXTURE_SIZE.");
8840 /* Check that INVALID_OPERATION is generated by TextureStorage2DMultisample if
8841 samples is greater than the value of MAX_SAMPLES. */
8843 gl.textureStorage2DMultisample(m_to_2D_ms, m_max_samples * 2, GL_R8, 8, 8, false);
8844 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage2DMultisample",
8845 "samples is greater than the value of MAX_SAMPLES.");
8848 /* Check that INVALID_OPERATION is generated by TextureStorage2DMultisample
8849 if the value of TEXTURE_IMMUTABLE_FORMAT for the texture bound to target
8852 gl.textureStorage2DMultisample(m_to_2D_ms_immutable, 1, GL_R8, 8, 8, false);
8853 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage2DMultisample",
8854 "samples is greater than the value of MAX_SAMPLES.");
8860 /** @brief Test TextureStorage3DMultisample
8862 * @return Test result.
8864 bool StorageErrorsTest::Test3DMultisample()
8866 /* Shortcut for GL functionality. */
8867 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8872 /* Check that INVALID_OPERATION is generated by TextureStorage3DMultisample
8873 if texture is not the name of an existing texture object. */
8875 gl.textureStorage3DMultisample(m_to_invalid, 1, GL_R8, 8, 8, 8, false);
8876 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage3DMultisample",
8877 "texture is not the name of an existing texture object.");
8880 /* Check that INVALID_ENUM is generated by TextureStorage3DMultisample if
8881 internalformat is not a valid color-renderable, depth-renderable or
8882 stencil-renderable format. */
8884 gl.textureStorage3DMultisample(m_to_3D_ms, 1, m_internalformat_invalid, 8, 8, 8, false);
8885 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureStorage3DMultisample",
8886 "internalformat is not a valid sized internal format.");
8889 /* Check that INVALID_OPERATION is generated by TextureStorage3DMultisample if
8890 target or the effective target of texture is not one of the accepted
8891 targets described above. */
8893 gl.textureStorage3DMultisample(m_to_1D, 1, GL_R8, 8, 8, 8, false);
8894 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage3DMultisample",
8895 "the effective target of texture is not one of the accepted targets.");
8898 /* Check that INVALID_VALUE is generated by TextureStorage3DMultisample if
8899 width or height are less than 1 or greater than the value of
8900 MAX_TEXTURE_SIZE. */
8902 gl.textureStorage3DMultisample(m_to_3D_ms, 1, GL_R8, 0, 8, 8, false);
8904 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage3DMultisample", "width is less than 1.");
8906 gl.textureStorage3DMultisample(m_to_3D_ms, 1, GL_R8, 8, 0, 8, false);
8908 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage3DMultisample", "height is less than 1.");
8910 gl.textureStorage3DMultisample(m_to_3D_ms, 1, GL_R8, m_max_texture_size * 2, 8, 8, false);
8911 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage3DMultisample",
8912 "width is greater than the value of MAX_TEXTURE_SIZE.");
8914 gl.textureStorage3DMultisample(m_to_3D_ms, 1, GL_R8, 8, m_max_texture_size * 2, 8, false);
8915 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage3DMultisample",
8916 "height is greater than the value of MAX_TEXTURE_SIZE.");
8919 /* Check that INVALID_VALUE is generated by TextureStorage3DMultisample if
8920 depth is less than 1 or greater than the value of
8921 MAX_ARRAY_TEXTURE_LAYERS. */
8923 gl.textureStorage3DMultisample(m_to_3D_ms, 1, GL_R8, 8, 8, 0, false);
8925 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage3DMultisample", "depth is less than 1.");
8927 gl.textureStorage3DMultisample(m_to_3D_ms, 1, GL_R8, 8, 8, m_max_array_texture_layers * 2, false);
8928 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureStorage3DMultisample",
8929 "depth is greater than the value of MAX_ARRAY_TEXTURE_LAYERS.");
8932 /* Check that INVALID_VALUE is generated by TextureStorage3DMultisample if
8933 samples is greater than the value of MAX_SAMPLES. */
8935 gl.textureStorage3DMultisample(m_to_3D_ms, m_max_samples * 2, GL_R8, 8, 8, 8, false);
8936 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage3DMultisample",
8937 "samples is greater than the value of MAX_SAMPLES.");
8940 /* Check that INVALID_OPERATION is generated by TextureStorage3DMultisample
8941 if the value of TEXTURE_IMMUTABLE_FORMAT for the texture bound to target
8944 gl.textureStorage3DMultisample(m_to_3D_ms_immutable, 1, GL_R8, 8, 8, 8, false);
8945 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage3DMultisample",
8946 "samples is greater than the value of MAX_SAMPLES.");
8952 /** @brief Clean GL objects, test variables and GL errors.
8954 void StorageErrorsTest::Clean()
8956 /* Shortcut for GL functionality. */
8957 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8962 gl.deleteTextures(1, &m_to_1D);
8969 gl.deleteTextures(1, &m_to_1D_array);
8976 gl.deleteTextures(1, &m_to_2D);
8983 gl.deleteTextures(1, &m_to_2D_array);
8990 gl.deleteTextures(1, &m_to_3D);
8997 gl.deleteTextures(1, &m_to_2D_ms);
9002 if (m_to_2D_ms_immutable)
9004 gl.deleteTextures(1, &m_to_2D_ms_immutable);
9006 m_to_2D_ms_immutable = 0;
9011 gl.deleteTextures(1, &m_to_3D_ms);
9016 if (m_to_3D_ms_immutable)
9018 gl.deleteTextures(1, &m_to_3D_ms_immutable);
9020 m_to_3D_ms_immutable = 0;
9024 m_internalformat_invalid = 0;
9025 m_max_texture_size = 1;
9027 m_max_array_texture_layers = 1;
9029 while (GL_NO_ERROR != gl.getError())
9033 /******************************** Texture SubImage Errors Test Implementation ********************************/
9035 /** @brief Texture SubImage Errors Test constructor.
9037 * @param [in] context OpenGL context.
9039 SubImageErrorsTest::SubImageErrorsTest(deqp::Context& context)
9040 : deqp::TestCase(context, "textures_subimage_errors", "Texture SubImage Errors Test")
9047 , m_to_1D_compressed(0)
9048 , m_to_2D_compressed(0)
9049 , m_to_3D_compressed(0)
9050 , m_to_rectangle_compressed(0)
9053 , m_format_invalid(0)
9055 , m_max_texture_size(1)
9056 , m_reference_compressed_1D(DE_NULL)
9057 , m_reference_compressed_2D(DE_NULL)
9058 , m_reference_compressed_3D(DE_NULL)
9059 , m_reference_compressed_rectangle(DE_NULL)
9060 , m_reference_compressed_1D_size(0)
9061 , m_reference_compressed_2D_size(0)
9062 , m_reference_compressed_3D_size(0)
9063 , m_reference_compressed_rectangle_size(0)
9064 , m_reference_compressed_1D_format(0)
9065 , m_reference_compressed_2D_format(0)
9066 , m_reference_compressed_3D_format(0)
9067 , m_reference_compressed_rectangle_format(0)
9068 , m_not_matching_compressed_1D_format(0)
9069 , m_not_matching_compressed_1D_size(0)
9070 , m_not_matching_compressed_2D_format(0)
9071 , m_not_matching_compressed_2D_size(0)
9072 , m_not_matching_compressed_3D_format(0)
9073 , m_not_matching_compressed_3D_size(0)
9075 /* Intentionally left blank. */
9078 /** @brief Iterate Texture SubImage Errors Test cases.
9080 * @return Iteration result.
9082 tcu::TestNode::IterateResult SubImageErrorsTest::iterate()
9084 /* Get context setup. */
9085 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
9086 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
9088 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
9090 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
9095 /* Running tests. */
9097 bool is_error = false;
9106 is_ok &= Test1DCompressed();
9107 is_ok &= Test2DCompressed();
9108 is_ok &= Test3DCompressed();
9119 /* Result's setup. */
9122 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
9128 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
9132 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
9139 /** @brief Prepare test's objects.
9141 void SubImageErrorsTest::Prepare()
9143 /* Shortcut for GL functionality. */
9144 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
9146 /* Auxiliary objects setup. */
9149 gl.createTextures(GL_TEXTURE_1D, 1, &m_to_1D_empty);
9150 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9153 gl.createTextures(GL_TEXTURE_2D, 1, &m_to_2D_empty);
9154 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9157 gl.createTextures(GL_TEXTURE_3D, 1, &m_to_3D_empty);
9158 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9161 gl.createTextures(GL_TEXTURE_1D, 1, &m_to_1D);
9162 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9164 gl.bindTexture(GL_TEXTURE_1D, m_to_1D);
9165 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
9167 gl.texImage1D(GL_TEXTURE_1D, 0, s_reference_internalformat, s_reference_width, 0, s_reference_format,
9168 GL_UNSIGNED_BYTE, s_reference);
9169 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
9172 gl.createTextures(GL_TEXTURE_2D, 1, &m_to_2D);
9173 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9175 gl.bindTexture(GL_TEXTURE_2D, m_to_2D);
9176 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
9178 gl.texImage2D(GL_TEXTURE_2D, 0, s_reference_internalformat, s_reference_width, s_reference_height, 0,
9179 s_reference_format, GL_UNSIGNED_BYTE, s_reference);
9180 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
9183 gl.createTextures(GL_TEXTURE_3D, 1, &m_to_3D);
9184 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9186 gl.bindTexture(GL_TEXTURE_3D, m_to_3D);
9187 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
9189 gl.texImage3D(GL_TEXTURE_3D, 0, s_reference_internalformat, s_reference_width, s_reference_height,
9190 s_reference_depth, 0, s_reference_format, GL_UNSIGNED_BYTE, s_reference);
9191 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
9194 gl.createTextures(GL_TEXTURE_1D, 1, &m_to_1D_compressed);
9195 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9197 gl.bindTexture(GL_TEXTURE_1D, m_to_1D_compressed);
9198 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
9200 gl.texImage1D(GL_TEXTURE_1D, 0, s_reference_internalformat_compressed, s_reference_width, 0, s_reference_format,
9201 GL_UNSIGNED_BYTE, s_reference);
9202 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
9204 glw::GLint is_compressed = 0;
9206 gl.getTexLevelParameteriv(GL_TEXTURE_1D, 0, GL_TEXTURE_COMPRESSED, &is_compressed);
9207 GLU_EXPECT_NO_ERROR(gl.getError(), "glTetTexLevelParameteriv has failed");
9211 gl.getTexLevelParameteriv(GL_TEXTURE_1D, 0, GL_TEXTURE_INTERNAL_FORMAT, &m_reference_compressed_1D_format);
9212 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9214 m_reference_compressed_1D_size = 0;
9216 gl.getTexLevelParameteriv(GL_TEXTURE_1D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &m_reference_compressed_1D_size);
9217 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9219 if (m_reference_compressed_1D_size)
9221 m_reference_compressed_1D = new glw::GLubyte[m_reference_compressed_1D_size];
9223 gl.getCompressedTexImage(GL_TEXTURE_1D, 0, m_reference_compressed_1D);
9224 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
9229 gl.createTextures(GL_TEXTURE_2D, 1, &m_to_2D_compressed);
9230 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9232 gl.bindTexture(GL_TEXTURE_2D, m_to_2D_compressed);
9233 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
9235 gl.texImage2D(GL_TEXTURE_2D, 0, s_reference_internalformat_compressed, s_reference_width, s_reference_height, 0,
9236 s_reference_format, GL_UNSIGNED_BYTE, s_reference);
9237 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
9241 gl.getTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED, &is_compressed);
9242 GLU_EXPECT_NO_ERROR(gl.getError(), "glTetTexLevelParameteriv has failed");
9246 gl.getTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &m_reference_compressed_2D_format);
9247 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9249 m_reference_compressed_2D_size = 0;
9251 gl.getTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &m_reference_compressed_2D_size);
9252 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9254 if (m_reference_compressed_2D_size)
9256 m_reference_compressed_2D = new glw::GLubyte[m_reference_compressed_2D_size];
9258 gl.getCompressedTexImage(GL_TEXTURE_2D, 0, m_reference_compressed_2D);
9259 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
9264 gl.createTextures(GL_TEXTURE_2D_ARRAY, 1, &m_to_3D_compressed);
9265 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9267 gl.bindTexture(GL_TEXTURE_2D_ARRAY, m_to_3D_compressed);
9268 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
9270 gl.texImage3D(GL_TEXTURE_2D_ARRAY, 0, s_reference_internalformat_compressed, s_reference_width, s_reference_height,
9271 s_reference_depth, 0, s_reference_format, GL_UNSIGNED_BYTE, s_reference);
9272 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage3D has failed");
9276 gl.getTexLevelParameteriv(GL_TEXTURE_2D_ARRAY, 0, GL_TEXTURE_COMPRESSED, &is_compressed);
9277 GLU_EXPECT_NO_ERROR(gl.getError(), "glTetTexLevelParameteriv has failed");
9281 gl.getTexLevelParameteriv(GL_TEXTURE_2D_ARRAY, 0, GL_TEXTURE_INTERNAL_FORMAT,
9282 &m_reference_compressed_3D_format);
9283 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9285 m_reference_compressed_3D_size = 0;
9287 gl.getTexLevelParameteriv(GL_TEXTURE_2D_ARRAY, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE,
9288 &m_reference_compressed_3D_size);
9289 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9291 if (m_reference_compressed_3D_size)
9293 m_reference_compressed_3D = new glw::GLubyte[m_reference_compressed_3D_size];
9295 gl.getCompressedTexImage(GL_TEXTURE_2D_ARRAY, 0, m_reference_compressed_3D);
9296 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
9300 /* RECTANGLE Compressed */
9301 gl.createTextures(GL_TEXTURE_RECTANGLE, 1, &m_to_rectangle_compressed);
9302 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9304 gl.bindTexture(GL_TEXTURE_RECTANGLE, m_to_rectangle_compressed);
9305 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
9307 gl.texImage2D(GL_TEXTURE_RECTANGLE, 0, s_reference_internalformat_compressed, s_reference_width, s_reference_height,
9308 0, s_reference_format, GL_UNSIGNED_BYTE, s_reference);
9309 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
9313 gl.getTexLevelParameteriv(GL_TEXTURE_RECTANGLE, 0, GL_TEXTURE_COMPRESSED, &is_compressed);
9314 GLU_EXPECT_NO_ERROR(gl.getError(), "glTetTexLevelParameteriv has failed");
9318 gl.getTexLevelParameteriv(GL_TEXTURE_RECTANGLE, 0, GL_TEXTURE_INTERNAL_FORMAT,
9319 &m_reference_compressed_rectangle_format);
9320 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9322 m_reference_compressed_rectangle_size = 0;
9324 gl.getTexLevelParameteriv(GL_TEXTURE_RECTANGLE, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE,
9325 &m_reference_compressed_rectangle_size);
9326 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9328 if (m_reference_compressed_rectangle_size)
9330 m_reference_compressed_rectangle = new glw::GLubyte[m_reference_compressed_rectangle_size];
9332 gl.getCompressedTexImage(GL_TEXTURE_RECTANGLE, 0, m_reference_compressed_rectangle);
9333 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetCompressedTexImage has failed");
9338 gl.createBuffers(1, &m_bo);
9339 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateBuffers has failed");
9341 gl.namedBufferData(m_bo, s_reference_size, s_reference, GL_STATIC_COPY);
9342 GLU_EXPECT_NO_ERROR(gl.getError(), "glNamedBufferData has failed");
9344 /* Invalid values */
9346 /* invalid texture object */
9347 while (gl.isTexture(++m_to_invalid))
9349 GLU_EXPECT_NO_ERROR(gl.getError(), "glIsTexture has failed");
9351 /* invalid internal format */
9352 static const glw::GLenum all_formats[] = { GL_STENCIL_INDEX,
9372 static const glw::GLuint all_internal_formats_count = sizeof(all_formats) / sizeof(all_formats[0]);
9374 bool is_valid = true;
9375 m_format_invalid = 0;
9381 for (glw::GLuint i = 0; i < all_internal_formats_count; ++i)
9383 if (all_formats[i] == m_format_invalid)
9392 static const glw::GLenum all_types[] = { GL_UNSIGNED_BYTE,
9400 GL_UNSIGNED_BYTE_3_3_2,
9401 GL_UNSIGNED_BYTE_2_3_3_REV,
9402 GL_UNSIGNED_SHORT_5_6_5,
9403 GL_UNSIGNED_SHORT_5_6_5_REV,
9404 GL_UNSIGNED_SHORT_4_4_4_4,
9405 GL_UNSIGNED_SHORT_4_4_4_4_REV,
9406 GL_UNSIGNED_SHORT_5_5_5_1,
9407 GL_UNSIGNED_SHORT_1_5_5_5_REV,
9408 GL_UNSIGNED_INT_8_8_8_8,
9409 GL_UNSIGNED_INT_8_8_8_8_REV,
9410 GL_UNSIGNED_INT_10_10_10_2,
9411 GL_UNSIGNED_INT_2_10_10_10_REV,
9412 GL_UNSIGNED_INT_24_8,
9413 GL_UNSIGNED_INT_10F_11F_11F_REV,
9414 GL_UNSIGNED_INT_5_9_9_9_REV,
9415 GL_FLOAT_32_UNSIGNED_INT_24_8_REV };
9417 static const glw::GLuint all_types_count = sizeof(all_types) / sizeof(all_types[0]);
9426 for (glw::GLuint i = 0; i < all_types_count; ++i)
9428 if (all_types[i] == m_type_invalid)
9436 /* Maximum texture size.*/
9437 gl.getIntegerv(GL_MAX_TEXTURE_SIZE, &m_max_texture_size);
9438 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
9440 glw::GLenum not_matching_format = GL_RED;
9441 glw::GLenum not_matching_internalformat_compressed = GL_COMPRESSED_RED;
9443 /* 1D Compressed with a non matching format. We need to do all the allocation to get the correct image size */
9444 glw::GLuint to_1D_compressed_not_matching;
9446 gl.createTextures(GL_TEXTURE_1D, 1, &to_1D_compressed_not_matching);
9447 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9449 gl.bindTexture(GL_TEXTURE_1D, to_1D_compressed_not_matching);
9450 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
9452 gl.texImage1D(GL_TEXTURE_1D, 0, not_matching_internalformat_compressed, s_reference_width, 0, s_reference_format,
9453 GL_UNSIGNED_BYTE, s_reference);
9454 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage1D has failed");
9458 gl.getTexLevelParameteriv(GL_TEXTURE_1D, 0, GL_TEXTURE_COMPRESSED, &is_compressed);
9459 GLU_EXPECT_NO_ERROR(gl.getError(), "glTetTexLevelParameteriv has failed");
9463 gl.getTexLevelParameteriv(GL_TEXTURE_1D, 0, GL_TEXTURE_INTERNAL_FORMAT, &m_not_matching_compressed_1D_format);
9464 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9466 m_not_matching_compressed_1D_size = 0;
9468 gl.getTexLevelParameteriv(GL_TEXTURE_1D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE,
9469 &m_not_matching_compressed_1D_size);
9470 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9473 gl.deleteTextures(1, &to_1D_compressed_not_matching);
9474 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9476 /* 2D Compressed with a non matching format. We need to do all the allocation to get the correct image size */
9477 glw::GLuint to_2D_compressed_not_matching;
9479 gl.createTextures(GL_TEXTURE_2D, 1, &to_2D_compressed_not_matching);
9480 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9482 gl.bindTexture(GL_TEXTURE_2D, to_2D_compressed_not_matching);
9483 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
9485 gl.texImage2D(GL_TEXTURE_2D, 0, not_matching_internalformat_compressed, s_reference_width, s_reference_height, 0,
9486 not_matching_format, GL_UNSIGNED_BYTE, s_reference);
9487 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
9491 gl.getTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED, &is_compressed);
9492 GLU_EXPECT_NO_ERROR(gl.getError(), "glTetTexLevelParameteriv has failed");
9496 gl.getTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &m_not_matching_compressed_2D_format);
9497 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9499 m_not_matching_compressed_2D_size = 0;
9501 gl.getTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE,
9502 &m_not_matching_compressed_2D_size);
9503 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9506 gl.deleteTextures(1, &to_2D_compressed_not_matching);
9507 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9509 /* 3D Compressed with a non matching format. We need to do all the allocation to get the correct image size */
9510 glw::GLuint to_3D_compressed_not_matching;
9512 gl.createTextures(GL_TEXTURE_3D, 1, &to_3D_compressed_not_matching);
9513 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9515 gl.bindTexture(GL_TEXTURE_3D, to_3D_compressed_not_matching);
9516 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
9518 gl.texImage3D(GL_TEXTURE_3D, 0, not_matching_internalformat_compressed, s_reference_width, s_reference_height,
9519 s_reference_depth, 0, not_matching_format, GL_UNSIGNED_BYTE, s_reference);
9520 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage3D has failed");
9524 gl.getTexLevelParameteriv(GL_TEXTURE_3D, 0, GL_TEXTURE_COMPRESSED, &is_compressed);
9525 GLU_EXPECT_NO_ERROR(gl.getError(), "glTetTexLevelParameteriv has failed");
9529 gl.getTexLevelParameteriv(GL_TEXTURE_3D, 0, GL_TEXTURE_INTERNAL_FORMAT, &m_not_matching_compressed_3D_format);
9530 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9532 m_not_matching_compressed_3D_size = 0;
9534 gl.getTexLevelParameteriv(GL_TEXTURE_3D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE,
9535 &m_not_matching_compressed_3D_size);
9536 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetTexLevelParameteriv has failed");
9539 gl.deleteTextures(1, &to_3D_compressed_not_matching);
9540 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
9543 /** @brief Test (negative) of TextureSubImage1D
9545 * @return Test result.
9547 bool SubImageErrorsTest::Test1D()
9549 /* Shortcut for GL functionality. */
9550 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
9555 /* Check that INVALID_OPERATION is generated by TextureSubImage1D if
9556 texture is not the name of an existing texture object. */
9558 gl.textureSubImage1D(m_to_invalid, 0, 0, s_reference_width, s_reference_format, s_reference_type, s_reference);
9559 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9560 "texture is not the name of an existing texture object.");
9563 /* Check that INVALID_ENUM is generated by TextureSubImage1D if format is
9564 not an accepted format constant. */
9566 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, m_format_invalid, s_reference_type, s_reference);
9567 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureSubImage1D",
9568 "format is not an accepted format constant.");
9571 /* Check that INVALID_ENUM is generated by TextureSubImage1D if type is not
9572 an accepted type constant. */
9574 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, m_type_invalid, s_reference);
9575 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureSubImage1D",
9576 "type is not an accepted type constant.");
9579 /* Check that INVALID_VALUE is generated by TextureSubImage1D if level is
9582 gl.textureSubImage1D(m_to_1D, -1, 0, s_reference_width, s_reference_format, s_reference_type, s_reference);
9583 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage1D", "level is less than 0.");
9586 /* Check that INVALID_VALUE may be generated by TextureSubImage1D if level
9587 is greater than log2 max, where max is the returned value of
9588 MAX_TEXTURE_SIZE. */
9590 gl.textureSubImage1D(m_to_1D, m_max_texture_size, 0, s_reference_width, s_reference_format, s_reference_type,
9593 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage1D",
9594 "level is greater than log2 max, where max is the returned value of MAX_TEXTURE_SIZE.");
9597 /* Check that INVALID_VALUE is generated by TextureSubImage1D if
9598 xoffset<-b, or if (xoffset+width)>(w-b), where w is the TEXTURE_WIDTH,
9599 and b is the width of the TEXTURE_BORDER of the texture image being
9600 modified. Note that w includes twice the border width. */
9602 gl.textureSubImage1D(m_to_1D, 0, -1, s_reference_width, s_reference_format, s_reference_type, s_reference);
9603 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage1D",
9604 "xoffset<-b, where b is the width of the TEXTURE_BORDER.");
9606 gl.textureSubImage1D(m_to_1D, 0, 1, s_reference_width + 1, s_reference_format, s_reference_type, s_reference);
9607 is_ok &= CheckErrorAndLog(
9608 m_context, GL_INVALID_VALUE, "glTextureSubImage1D",
9609 "(xoffset+width)>(w-b), where w is the TEXTURE_WIDTH, b is the width of the TEXTURE_BORDER.");
9612 /*Check that INVALID_VALUE is generated by TextureSubImage1D if width is less than 0. */
9614 #ifndef TURN_OFF_SUB_IMAGE_ERRORS_TEST_OF_NEGATIVE_WIDTH_HEIGHT_OR_DEPTH
9615 gl.textureSubImage1D(m_to_1D, 0, 0, -1, s_reference_format, s_reference_type, s_reference);
9616 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage1D", "width is less than 0.");
9620 /* Check that INVALID_OPERATION is generated by TextureSubImage1D if type
9621 is one of UNSIGNED_BYTE_3_3_2, UNSIGNED_BYTE_2_3_3_REV,
9622 UNSIGNED_SHORT_5_6_5, or UNSIGNED_SHORT_5_6_5_REV and format is not RGB. */
9624 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_BYTE_3_3_2, s_reference);
9625 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9626 "type is UNSIGNED_BYTE_3_3_2 and format is not RGB.");
9628 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_BYTE_2_3_3_REV,
9630 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9631 "type is UNSIGNED_BYTE_2_3_3_REV and format is not RGB.");
9633 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_SHORT_5_6_5,
9635 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9636 "type is UNSIGNED_SHORT_5_6_5 and format is not RGB.");
9638 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_SHORT_5_6_5_REV,
9640 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9641 "type is UNSIGNED_SHORT_5_6_5_REV and format is not RGB.");
9644 /* Check that INVALID_OPERATION is generated by TextureSubImage1D if type
9645 is one of UNSIGNED_SHORT_4_4_4_4, UNSIGNED_SHORT_4_4_4_4_REV,
9646 UNSIGNED_SHORT_5_5_5_1, UNSIGNED_SHORT_1_5_5_5_REV,
9647 UNSIGNED_INT_8_8_8_8, UNSIGNED_INT_8_8_8_8_REV, UNSIGNED_INT_10_10_10_2,
9648 or UNSIGNED_INT_2_10_10_10_REV and format is neither RGBA nor BGRA. */
9650 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_SHORT_4_4_4_4,
9652 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9653 "type is UNSIGNED_SHORT_4_4_4_4 and format is neither RGBA nor BGRA.");
9655 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_SHORT_4_4_4_4_REV,
9657 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9658 "type is UNSIGNED_SHORT_4_4_4_4_REV and format is neither RGBA nor BGRA.");
9660 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_SHORT_5_5_5_1,
9662 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9663 "type is UNSIGNED_SHORT_5_5_5_1 and format is neither RGBA nor BGRA.");
9665 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_SHORT_1_5_5_5_REV,
9667 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9668 "type is UNSIGNED_SHORT_1_5_5_5_REV and format is neither RGBA nor BGRA.");
9670 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_INT_8_8_8_8,
9672 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9673 "type is UNSIGNED_INT_8_8_8_8 and format is neither RGBA nor BGRA.");
9675 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_INT_8_8_8_8_REV,
9677 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9678 "type is UNSIGNED_INT_8_8_8_8_REV and format is neither RGBA nor BGRA.");
9680 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_INT_10_10_10_2,
9682 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9683 "type is UNSIGNED_INT_10_10_10_2 and format is neither RGBA nor BGRA.");
9685 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, GL_UNSIGNED_INT_2_10_10_10_REV,
9687 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9688 "type is UNSIGNED_INT_2_10_10_10_REV and format is neither RGBA nor BGRA.");
9691 /* Check that INVALID_OPERATION is generated by TextureSubImage1D if a
9692 non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
9693 and the buffer object's data store is currently mapped. */
9695 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
9696 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9698 gl.mapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_READ_WRITE);
9700 if (GL_NO_ERROR == gl.getError())
9702 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, s_reference_type, NULL);
9703 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9704 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and "
9705 "the buffer object's data store is currently mapped.");
9707 gl.unmapBuffer(GL_PIXEL_UNPACK_BUFFER);
9708 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9710 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
9711 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9715 /* Check that INVALID_OPERATION is generated by TextureSubImage1D if a
9716 non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
9717 and the data would be unpacked from the buffer object such that the
9718 memory reads required would exceed the data store size. */
9720 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
9721 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9723 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, s_reference_type,
9724 (glw::GLubyte*)NULL + s_reference_size * 2);
9725 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9726 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and the "
9727 "data would be unpacked from the buffer object such that the memory reads required "
9728 "would exceed the data store size.");
9730 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
9731 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9734 /* Check that INVALID_OPERATION is generated by TextureSubImage1D if a
9735 non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
9736 and pixels is not evenly divisible into the number of bytes needed to
9737 store in memory a datum indicated by type. */
9739 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
9740 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9742 gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, s_reference_type,
9743 (glw::GLubyte*)NULL + 1);
9744 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
9745 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and pixels "
9746 "is not evenly divisible into the number of bytes needed to store in memory a datum "
9747 "indicated by type.");
9749 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
9750 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9756 /** @brief Test (negative) of TextureSubImage2D
9758 * @return Test result.
9760 bool SubImageErrorsTest::Test2D()
9762 /* Shortcut for GL functionality. */
9763 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
9768 /* Check that INVALID_OPERATION is generated by TextureSubImage2D if
9769 texture is not the name of an existing texture object. */
9771 gl.textureSubImage2D(m_to_invalid, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9772 s_reference_type, s_reference);
9773 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9774 "texture is not the name of an existing texture object.");
9777 /* Check that INVALID_ENUM is generated by TextureSubImage2D if format is
9778 not an accepted format constant. */
9780 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, m_format_invalid,
9781 s_reference_type, s_reference);
9782 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureSubImage2D",
9783 "format is not an accepted format constant.");
9786 /* Check that INVALID_ENUM is generated by TextureSubImage2D if type is not
9787 an accepted type constant. */
9789 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9790 m_type_invalid, s_reference);
9791 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureSubImage2D",
9792 "type is not an accepted type constant.");
9795 /* Check that INVALID_VALUE is generated by TextureSubImage2D if level is
9798 gl.textureSubImage2D(m_to_2D, -1, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9799 s_reference_type, s_reference);
9800 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage2D", "level is less than 0.");
9803 /* Check that INVALID_VALUE may be generated by TextureSubImage2D if level
9804 is greater than log2 max, where max is the returned value of
9805 MAX_TEXTURE_SIZE. */
9807 gl.textureSubImage2D(m_to_2D, m_max_texture_size, 0, 0, s_reference_width, s_reference_height,
9808 s_reference_format, s_reference_type, s_reference);
9810 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage2D",
9811 "level is greater than log2 max, where max is the returned value of MAX_TEXTURE_SIZE.");
9814 /* Check that INVALID_VALUE may be generated by TextureSubImage2D if level
9815 is greater than log2 max, where max is the returned value of
9817 Check that INVALID_VALUE is generated by TextureSubImage2D if
9818 xoffset<-b, (xoffset+width)>(w-b), yoffset<-b, or
9819 (yoffset+height)>(h-b), where w is the TEXTURE_WIDTH, h is the
9820 TEXTURE_HEIGHT, and b is the border width of the texture image being
9821 modified. Note that w and h include twice the border width. */
9823 gl.textureSubImage2D(m_to_2D, 0, -1, 0, s_reference_width, s_reference_height, s_reference_format,
9824 s_reference_type, s_reference);
9825 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage2D",
9826 "xoffset<-b, where b is the width of the TEXTURE_BORDER.");
9828 gl.textureSubImage2D(m_to_2D, 0, 1, 0, s_reference_width + 1, s_reference_height, s_reference_format,
9829 s_reference_type, s_reference);
9830 is_ok &= CheckErrorAndLog(
9831 m_context, GL_INVALID_VALUE, "glTextureSubImage2D",
9832 "(xoffset+width)>(w-b), where w is the TEXTURE_WIDTH, b is the width of the TEXTURE_BORDER.");
9834 gl.textureSubImage2D(m_to_2D, 0, 0, -1, s_reference_width, s_reference_height, s_reference_format,
9835 s_reference_type, s_reference);
9836 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage2D",
9837 "yoffset<-b, where b is the height of the TEXTURE_BORDER.");
9839 gl.textureSubImage2D(m_to_2D, 0, 0, 1, s_reference_width + 1, s_reference_height, s_reference_format,
9840 s_reference_type, s_reference);
9841 is_ok &= CheckErrorAndLog(
9842 m_context, GL_INVALID_VALUE, "glTextureSubImage2D",
9843 "(yoffset+height)>(h-b), where h is the TEXTURE_HEIGHT, b is the width of the TEXTURE_BORDER.");
9846 /*Check that INVALID_VALUE is generated by TextureSubImage2D if width or height is less than 0. */
9848 #ifndef TURN_OFF_SUB_IMAGE_ERRORS_TEST_OF_NEGATIVE_WIDTH_HEIGHT_OR_DEPTH
9849 gl.textureSubImage2D(m_to_2D, 0, 0, 0, -1, s_reference_height, s_reference_format, s_reference_type,
9851 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage2D", "width is less than 0.");
9853 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, -1, s_reference_format, s_reference_type,
9855 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage2D", "height is less than 0.");
9859 /* Check that INVALID_OPERATION is generated by TextureSubImage2D if type
9860 is one of UNSIGNED_BYTE_3_3_2, UNSIGNED_BYTE_2_3_3_REV,
9861 UNSIGNED_SHORT_5_6_5, or UNSIGNED_SHORT_5_6_5_REV and format is not RGB. */
9863 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9864 GL_UNSIGNED_BYTE_3_3_2, s_reference);
9865 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9866 "type is UNSIGNED_BYTE_3_3_2 and format is not RGB.");
9868 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9869 GL_UNSIGNED_BYTE_2_3_3_REV, s_reference);
9870 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9871 "type is UNSIGNED_BYTE_2_3_3_REV and format is not RGB.");
9873 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9874 GL_UNSIGNED_SHORT_5_6_5, s_reference);
9875 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9876 "type is UNSIGNED_SHORT_5_6_5 and format is not RGB.");
9878 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9879 GL_UNSIGNED_SHORT_5_6_5_REV, s_reference);
9880 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9881 "type is UNSIGNED_SHORT_5_6_5_REV and format is not RGB.");
9884 /* Check that INVALID_OPERATION is generated by TextureSubImage2D if type
9885 is one of UNSIGNED_SHORT_4_4_4_4, UNSIGNED_SHORT_4_4_4_4_REV,
9886 UNSIGNED_SHORT_5_5_5_1, UNSIGNED_SHORT_1_5_5_5_REV,
9887 UNSIGNED_INT_8_8_8_8, UNSIGNED_INT_8_8_8_8_REV, UNSIGNED_INT_10_10_10_2,
9888 or UNSIGNED_INT_2_10_10_10_REV and format is neither RGBA nor BGRA. */
9890 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9891 GL_UNSIGNED_SHORT_4_4_4_4, s_reference);
9892 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9893 "type is UNSIGNED_SHORT_4_4_4_4 and format is neither RGBA nor BGRA.");
9895 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9896 GL_UNSIGNED_SHORT_4_4_4_4_REV, s_reference);
9897 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9898 "type is UNSIGNED_SHORT_4_4_4_4_REV and format is neither RGBA nor BGRA.");
9900 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9901 GL_UNSIGNED_SHORT_5_5_5_1, s_reference);
9902 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9903 "type is UNSIGNED_SHORT_5_5_5_1 and format is neither RGBA nor BGRA.");
9905 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9906 GL_UNSIGNED_SHORT_1_5_5_5_REV, s_reference);
9907 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9908 "type is UNSIGNED_SHORT_1_5_5_5_REV and format is neither RGBA nor BGRA.");
9910 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9911 GL_UNSIGNED_INT_8_8_8_8, s_reference);
9912 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9913 "type is UNSIGNED_INT_8_8_8_8 and format is neither RGBA nor BGRA.");
9915 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9916 GL_UNSIGNED_INT_8_8_8_8_REV, s_reference);
9917 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9918 "type is UNSIGNED_INT_8_8_8_8_REV and format is neither RGBA nor BGRA.");
9920 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9921 GL_UNSIGNED_INT_10_10_10_2, s_reference);
9922 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9923 "type is UNSIGNED_INT_10_10_10_2 and format is neither RGBA nor BGRA.");
9925 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9926 GL_UNSIGNED_INT_2_10_10_10_REV, s_reference);
9927 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9928 "type is UNSIGNED_INT_2_10_10_10_REV and format is neither RGBA nor BGRA.");
9931 /* Check that INVALID_OPERATION is generated by TextureSubImage2D if a
9932 non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
9933 and the buffer object's data store is currently mapped. */
9935 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
9936 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9938 gl.mapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_READ_WRITE);
9940 if (GL_NO_ERROR == gl.getError())
9942 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9943 s_reference_type, NULL);
9944 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9945 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and "
9946 "the buffer object's data store is currently mapped.");
9948 gl.unmapBuffer(GL_PIXEL_UNPACK_BUFFER);
9949 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9951 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
9952 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9956 /* Check that INVALID_OPERATION is generated by TextureSubImage2D if a
9957 non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
9958 and the data would be unpacked from the buffer object such that the
9959 memory reads required would exceed the data store size. */
9961 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
9962 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9964 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9965 s_reference_type, (glw::GLubyte*)NULL + s_reference_size * 2);
9966 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9967 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and the "
9968 "data would be unpacked from the buffer object such that the memory reads required "
9969 "would exceed the data store size.");
9971 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
9972 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9975 /* Check that INVALID_OPERATION is generated by TextureSubImage2D if a
9976 non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
9977 and pixels is not evenly divisible into the number of bytes needed to
9978 store in memory a datum indicated by type. */
9980 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
9981 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9983 gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
9984 s_reference_type, (glw::GLubyte*)NULL + 1);
9985 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
9986 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and pixels "
9987 "is not evenly divisible into the number of bytes needed to store in memory a datum "
9988 "indicated by type.");
9990 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
9991 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
9997 /** @brief Test (negative) of TextureSubImage3D
9999 * @return Test result.
10001 bool SubImageErrorsTest::Test3D()
10003 /* Shortcut for GL functionality. */
10004 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
10009 /* Check that INVALID_OPERATION is generated by TextureSubImage3D if
10010 texture is not the name of an existing texture object. */
10012 gl.textureSubImage3D(m_to_invalid, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10013 s_reference_format, s_reference_type, s_reference);
10014 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10015 "texture is not the name of an existing texture object.");
10018 /* Check that INVALID_ENUM is generated by TextureSubImage3D if format is
10019 not an accepted format constant. */
10021 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10022 m_format_invalid, s_reference_type, s_reference);
10023 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureSubImage3D",
10024 "format is not an accepted format constant.");
10027 /* Check that INVALID_ENUM is generated by TextureSubImage3D if type is not
10028 an accepted type constant. */
10030 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10031 s_reference_format, m_type_invalid, s_reference);
10032 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureSubImage3D",
10033 "type is not an accepted type constant.");
10036 /* Check that INVALID_VALUE is generated by TextureSubImage3D if level is
10039 gl.textureSubImage3D(m_to_3D, -1, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10040 s_reference_format, s_reference_type, s_reference);
10041 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage3D", "level is less than 0.");
10044 /* Check that INVALID_VALUE may be generated by TextureSubImage1D if level
10045 is greater than log2 max, where max is the returned value of
10046 MAX_TEXTURE_SIZE. */
10048 gl.textureSubImage3D(m_to_3D, m_max_texture_size, 0, 0, 0, s_reference_width, s_reference_height,
10049 s_reference_depth, s_reference_format, s_reference_type, s_reference);
10051 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage3D",
10052 "level is greater than log2 max, where max is the returned value of MAX_TEXTURE_SIZE.");
10055 /* Check that INVALID_VALUE is generated by TextureSubImage3D if
10056 xoffset<-b, (xoffset+width)>(w-b), yoffset<-b, or
10057 (yoffset+height)>(h-b), or zoffset<-b, or (zoffset+depth)>(d-b), where w
10058 is the TEXTURE_WIDTH, h is the TEXTURE_HEIGHT, d is the TEXTURE_DEPTH
10059 and b is the border width of the texture image being modified. Note
10060 that w, h, and d include twice the border width. */
10062 gl.textureSubImage3D(m_to_3D, 0, -1, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10063 s_reference_format, s_reference_type, s_reference);
10064 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage3D",
10065 "xoffset<-b, where b is the width of the TEXTURE_BORDER.");
10067 gl.textureSubImage3D(m_to_3D, 0, 1, 0, 0, s_reference_width + 1, s_reference_height, s_reference_depth,
10068 s_reference_format, s_reference_type, s_reference);
10069 is_ok &= CheckErrorAndLog(
10070 m_context, GL_INVALID_VALUE, "glTextureSubImage3D",
10071 "(xoffset+width)>(w-b), where w is the TEXTURE_WIDTH, b is the width of the TEXTURE_BORDER.");
10073 gl.textureSubImage3D(m_to_3D, 0, 0, -1, 0, s_reference_width, s_reference_height, s_reference_depth,
10074 s_reference_format, s_reference_type, s_reference);
10075 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage3D",
10076 "yoffset<-b, where b is the width of the TEXTURE_BORDER.");
10078 gl.textureSubImage3D(m_to_3D, 0, 0, 1, 0, s_reference_width + 1, s_reference_height, s_reference_depth,
10079 s_reference_format, s_reference_type, s_reference);
10080 is_ok &= CheckErrorAndLog(
10081 m_context, GL_INVALID_VALUE, "glTextureSubImage3D",
10082 "(yoffset+height)>(h-b), where h is the TEXTURE_HEIGHT, b is the width of the TEXTURE_BORDER.");
10084 gl.textureSubImage3D(m_to_3D, 0, 0, 0, -1, s_reference_width, s_reference_height, s_reference_depth,
10085 s_reference_format, s_reference_type, s_reference);
10086 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage3D",
10087 "zoffset<-b, where b is the depth of the TEXTURE_BORDER.");
10089 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 1, s_reference_width + 1, s_reference_height, s_reference_depth,
10090 s_reference_format, s_reference_type, s_reference);
10091 is_ok &= CheckErrorAndLog(
10092 m_context, GL_INVALID_VALUE, "glTextureSubImage3D",
10093 "(zoffset+width)>(d-b), where d is the TEXTURE_DEPTH, b is the width of the TEXTURE_BORDER.");
10096 /*Check that INVALID_VALUE is generated by TextureSubImage3D if width or height or depth is less than 0. */
10098 #ifndef TURN_OFF_SUB_IMAGE_ERRORS_TEST_OF_NEGATIVE_WIDTH_HEIGHT_OR_DEPTH
10099 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, -1, s_reference_height, s_reference_depth, s_reference_format,
10100 s_reference_type, s_reference);
10101 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage1D", "width is less than 0.");
10103 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, -1, s_reference_depth, s_reference_format,
10104 s_reference_type, s_reference);
10105 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage1D", "height is less than 0.");
10107 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, -1, s_reference_format,
10108 s_reference_type, s_reference);
10109 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureSubImage1D", "depth is less than 0.");
10113 /* Check that INVALID_OPERATION is generated by TextureSubImage3D if type
10114 is one of UNSIGNED_BYTE_3_3_2, UNSIGNED_BYTE_2_3_3_REV,
10115 UNSIGNED_SHORT_5_6_5, or UNSIGNED_SHORT_5_6_5_REV and format is not RGB. */
10117 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10118 s_reference_format, GL_UNSIGNED_BYTE_3_3_2, s_reference);
10119 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10120 "type is UNSIGNED_BYTE_3_3_2 and format is not RGB.");
10122 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10123 s_reference_format, GL_UNSIGNED_BYTE_2_3_3_REV, s_reference);
10124 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10125 "type is UNSIGNED_BYTE_2_3_3_REV and format is not RGB.");
10127 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10128 s_reference_format, GL_UNSIGNED_SHORT_5_6_5, s_reference);
10129 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10130 "type is UNSIGNED_SHORT_5_6_5 and format is not RGB.");
10132 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10133 s_reference_format, GL_UNSIGNED_SHORT_5_6_5_REV, s_reference);
10134 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10135 "type is UNSIGNED_SHORT_5_6_5_REV and format is not RGB.");
10138 /* Check that INVALID_OPERATION is generated by TextureSubImage3D if type
10139 is one of UNSIGNED_SHORT_4_4_4_4, UNSIGNED_SHORT_4_4_4_4_REV,
10140 UNSIGNED_SHORT_5_5_5_1, UNSIGNED_SHORT_1_5_5_5_REV,
10141 UNSIGNED_INT_8_8_8_8, UNSIGNED_INT_8_8_8_8_REV, UNSIGNED_INT_10_10_10_2,
10142 or UNSIGNED_INT_2_10_10_10_REV and format is neither RGBA nor BGRA. */
10144 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10145 s_reference_format, GL_UNSIGNED_SHORT_4_4_4_4, s_reference);
10146 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10147 "type is UNSIGNED_SHORT_4_4_4_4 and format is neither RGBA nor BGRA.");
10149 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10150 s_reference_format, GL_UNSIGNED_SHORT_4_4_4_4_REV, s_reference);
10151 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10152 "type is UNSIGNED_SHORT_4_4_4_4_REV and format is neither RGBA nor BGRA.");
10154 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10155 s_reference_format, GL_UNSIGNED_SHORT_5_5_5_1, s_reference);
10156 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10157 "type is UNSIGNED_SHORT_5_5_5_1 and format is neither RGBA nor BGRA.");
10159 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10160 s_reference_format, GL_UNSIGNED_SHORT_1_5_5_5_REV, s_reference);
10161 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10162 "type is UNSIGNED_SHORT_1_5_5_5_REV and format is neither RGBA nor BGRA.");
10164 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10165 s_reference_format, GL_UNSIGNED_INT_8_8_8_8, s_reference);
10166 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10167 "type is UNSIGNED_INT_8_8_8_8 and format is neither RGBA nor BGRA.");
10169 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10170 s_reference_format, GL_UNSIGNED_INT_8_8_8_8_REV, s_reference);
10171 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10172 "type is UNSIGNED_INT_8_8_8_8_REV and format is neither RGBA nor BGRA.");
10174 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10175 s_reference_format, GL_UNSIGNED_INT_10_10_10_2, s_reference);
10176 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10177 "type is UNSIGNED_INT_10_10_10_2 and format is neither RGBA nor BGRA.");
10179 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10180 s_reference_format, GL_UNSIGNED_INT_2_10_10_10_REV, s_reference);
10181 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10182 "type is UNSIGNED_INT_2_10_10_10_REV and format is neither RGBA nor BGRA.");
10185 /* Check that INVALID_OPERATION is generated by TextureSubImage3D if a
10186 non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
10187 and the buffer object's data store is currently mapped. */
10189 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
10190 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10192 gl.mapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_READ_WRITE);
10194 if (GL_NO_ERROR == gl.getError())
10196 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10197 s_reference_format, s_reference_type, NULL);
10198 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10199 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and "
10200 "the buffer object's data store is currently mapped.");
10202 gl.unmapBuffer(GL_PIXEL_UNPACK_BUFFER);
10203 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10205 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10206 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10210 /* Check that INVALID_OPERATION is generated by TextureSubImage3D if a
10211 non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
10212 and the data would be unpacked from the buffer object such that the
10213 memory reads required would exceed the data store size. */
10215 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
10216 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10218 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10219 s_reference_format, s_reference_type, (glw::GLubyte*)NULL + s_reference_size * 2);
10220 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10221 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and the "
10222 "data would be unpacked from the buffer object such that the memory reads required "
10223 "would exceed the data store size.");
10225 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10226 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10229 /* Check that INVALID_OPERATION is generated by TextureSubImage3D if a
10230 non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target
10231 and pixels is not evenly divisible into the number of bytes needed to
10232 store in memory a datum indicated by type. */
10234 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
10235 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10237 gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
10238 s_reference_format, s_reference_type, (glw::GLubyte*)NULL + 1);
10239 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
10240 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and pixels "
10241 "is not evenly divisible into the number of bytes needed to store in memory a datum "
10242 "indicated by type.");
10244 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10245 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10251 /** @brief Test (negative) of TextureSubImage1DCompressed
10253 * @return Test result.
10255 bool SubImageErrorsTest::Test1DCompressed()
10257 /* Shortcut for GL functionality. */
10258 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
10263 /* Do tests only if compressed 1D textures are supported. */
10264 if (DE_NULL != m_reference_compressed_1D)
10266 /* Check that INVALID_OPERATION is generated by CompressedTextureSubImage1D
10267 if texture is not the name of an existing texture object. */
10269 gl.compressedTextureSubImage1D(m_to_invalid, 0, 0, s_reference_width, m_reference_compressed_1D_format,
10270 m_reference_compressed_1D_size, m_reference_compressed_1D);
10271 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage1D",
10272 "texture is not the name of an existing texture object.");
10275 /* Check that INVALID_ENUM is generated by CompressedTextureSubImage1D if
10276 internalformat is not one of the generic compressed internal formats:
10277 COMPRESSED_RED, COMPRESSED_RG, COMPRESSED_RGB, COMPRESSED_RGBA.
10278 COMPRESSED_SRGB, or COMPRESSED_SRGB_ALPHA. */
10280 /* GL_COMPRESSED_RG_RGTC2 is not 1D as specification says. */
10281 gl.compressedTextureSubImage1D(m_to_1D_compressed, 0, 0, s_reference_width, GL_COMPRESSED_RG_RGTC2,
10282 m_reference_compressed_1D_size, m_reference_compressed_1D);
10283 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glCompressedTextureSubImage1D",
10284 "internalformat is of the generic compressed internal formats: COMPRESSED_RED, "
10285 "COMPRESSED_RG, COMPRESSED_RGB, COMPRESSED_RGBA. COMPRESSED_SRGB, or "
10286 "COMPRESSED_SRGB_ALPHA.");
10289 /* Check that INVALID_OPERATION is generated if format does not match the
10290 internal format of the texture image being modified, since these
10291 commands do not provide for image format conversion. */
10293 gl.compressedTextureSubImage1D(m_to_1D_compressed, 0, 0, s_reference_width,
10294 m_not_matching_compressed_1D_format, m_not_matching_compressed_1D_size,
10295 m_reference_compressed_1D);
10296 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage1D",
10297 "format does not match the internal format of the texture image being modified, "
10298 "since these commands do not provide for image format conversion.");
10301 /* Check that INVALID_VALUE is generated by CompressedTextureSubImage1D if
10302 imageSize is not consistent with the format, dimensions, and contents of
10303 the specified compressed image data. */
10305 gl.compressedTextureSubImage1D(m_to_1D_compressed, 0, 0, s_reference_width,
10306 m_reference_compressed_1D_format, m_reference_compressed_1D_size - 1,
10307 m_reference_compressed_1D);
10308 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCompressedTextureSubImage1D",
10309 "imageSize is not consistent with the format, dimensions, and contents of the "
10310 "specified compressed image data.");
10313 /* Check that INVALID_OPERATION is generated by CompressedTextureSubImage1D
10314 if a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER
10315 target and the buffer object's data store is currently mapped. */
10317 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
10318 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10320 gl.mapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_READ_WRITE);
10322 if (GL_NO_ERROR == gl.getError())
10324 gl.compressedTextureSubImage1D(m_to_1D_compressed, 0, 0, s_reference_width,
10325 m_reference_compressed_1D_format, m_reference_compressed_1D_size, NULL);
10326 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage1D",
10327 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target "
10328 "and the buffer object's data store is currently mapped.");
10330 gl.unmapBuffer(GL_PIXEL_UNPACK_BUFFER);
10331 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10333 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10334 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10338 /* Check that INVALID_OPERATION is generated by CompressedTextureSubImage1D
10339 if a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER
10340 target and the data would be unpacked from the buffer object such that
10341 the memory reads required would exceed the data store size. */
10343 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
10344 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10346 gl.compressedTextureSubImage1D(m_to_1D_compressed, 0, 0, s_reference_width,
10347 m_reference_compressed_1D_format, m_reference_compressed_1D_size,
10348 (glw::GLubyte*)NULL + s_reference_size * 2);
10349 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage1D",
10350 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and "
10351 "the buffer object's data store is currently mapped.");
10353 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10354 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10361 /** @brief Test (negative) of TextureSubImage2DCompressed
10363 * @return Test result.
10365 bool SubImageErrorsTest::Test2DCompressed()
10367 /* Shortcut for GL functionality. */
10368 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
10373 /* Do tests only if compressed 2D textures are supported. */
10374 if (DE_NULL != m_reference_compressed_2D)
10376 /* Check that INVALID_OPERATION is generated by CompressedTextureSubImage2D
10377 if texture is not the name of an existing texture object. */
10379 gl.compressedTextureSubImage2D(m_to_invalid, 0, 0, 0, s_reference_width, s_reference_height,
10380 m_reference_compressed_2D_format, m_reference_compressed_2D_size,
10381 m_reference_compressed_2D);
10382 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage2D",
10383 "texture is not the name of an existing texture object.");
10386 /* Check that INVALID_ENUM is generated by CompressedTextureSubImage2D if
10387 internalformat is of the generic compressed internal formats:
10388 COMPRESSED_RED, COMPRESSED_RG, COMPRESSED_RGB, COMPRESSED_RGBA.
10389 COMPRESSED_SRGB, or COMPRESSED_SRGB_ALPHA. */
10391 gl.compressedTextureSubImage2D(m_to_2D_compressed, 0, 0, 0, s_reference_width, s_reference_height,
10392 GL_COMPRESSED_RG, m_reference_compressed_2D_size, m_reference_compressed_2D);
10393 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glCompressedTextureSubImage2D",
10394 "internalformat is of the generic compressed internal formats: COMPRESSED_RED, "
10395 "COMPRESSED_RG, COMPRESSED_RGB, COMPRESSED_RGBA. COMPRESSED_SRGB, or "
10396 "COMPRESSED_SRGB_ALPHA.");
10399 /* Check that INVALID_OPERATION is generated if format does not match the
10400 internal format of the texture image being modified, since these
10401 commands do not provide for image format conversion. */
10403 gl.compressedTextureSubImage2D(m_to_2D_compressed, 0, 0, 0, s_reference_width, s_reference_height,
10404 m_not_matching_compressed_2D_format, m_not_matching_compressed_2D_size,
10405 m_reference_compressed_2D);
10406 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage2D",
10407 "format does not match the internal format of the texture image being modified, "
10408 "since these commands do not provide for image format conversion.");
10411 /* Check that INVALID_VALUE is generated by CompressedTextureSubImage2D if
10412 imageSize is not consistent with the format, dimensions, and contents of
10413 the specified compressed image data. */
10415 gl.compressedTextureSubImage2D(m_to_2D_compressed, 0, 0, 0, s_reference_width, s_reference_height,
10416 m_reference_compressed_2D_format, m_reference_compressed_2D_size - 1,
10417 m_reference_compressed_2D);
10418 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCompressedTextureSubImage2D",
10419 "imageSize is not consistent with the format, dimensions, and contents of the "
10420 "specified compressed image data.");
10423 /* Check that INVALID_OPERATION is generated by CompressedTextureSubImage2D
10424 if a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER
10425 target and the buffer object's data store is currently mapped. */
10427 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
10428 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10430 gl.mapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_READ_WRITE);
10432 if (GL_NO_ERROR == gl.getError())
10434 gl.compressedTextureSubImage2D(m_to_2D_compressed, 0, 0, 0, s_reference_width, s_reference_height,
10435 m_reference_compressed_2D_format, m_reference_compressed_2D_size, NULL);
10436 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage2D",
10437 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target "
10438 "and the buffer object's data store is currently mapped.");
10440 gl.unmapBuffer(GL_PIXEL_UNPACK_BUFFER);
10441 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10443 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10444 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10448 /* Check that INVALID_OPERATION is generated by CompressedTextureSubImage2D
10449 if a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER
10450 target and the data would be unpacked from the buffer object such that
10451 the memory reads required would exceed the data store size. */
10453 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
10454 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10456 gl.compressedTextureSubImage2D(m_to_2D_compressed, 0, 0, 0, s_reference_width, s_reference_height,
10457 m_reference_compressed_2D_format, m_reference_compressed_2D_size,
10458 (glw::GLubyte*)NULL + s_reference_size * 2);
10459 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage2D",
10460 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and "
10461 "the buffer object's data store is currently mapped.");
10463 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10464 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10467 /* Check that INVALID_OPERATION is generated by CompressedTextureSubImage2D
10468 if the effective target is TEXTURE_RECTANGLE. */
10470 m_reference_compressed_rectangle) /* Do test only if rectangle compressed texture is supported by the implementation. */
10472 gl.compressedTextureSubImage2D(m_to_rectangle_compressed, 0, 0, 0, s_reference_width, s_reference_height,
10473 m_reference_compressed_rectangle_format,
10474 m_reference_compressed_rectangle_size, m_reference_compressed_rectangle);
10476 if (m_context.getContextInfo().isExtensionSupported("GL_NV_texture_rectangle_compressed"))
10478 is_ok &= CheckErrorAndLog(m_context, GL_NO_ERROR, "glCompressedTextureSubImage2D",
10479 "a rectangle texture object is used with this function.");
10483 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage2D",
10484 "a rectangle texture object is used with this function.");
10492 /** @brief Test (negative) of TextureSubImage3DCompressed
10494 * @return Test result.
10496 bool SubImageErrorsTest::Test3DCompressed()
10498 /* Shortcut for GL functionality. */
10499 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
10504 /* Do tests only if compressed 3D textures are supported. */
10505 if (DE_NULL != m_reference_compressed_3D)
10507 /* Check that INVALID_OPERATION is generated by CompressedTextureSubImage3D
10508 if texture is not the name of an existing texture object. */
10510 gl.compressedTextureSubImage3D(m_to_invalid, 0, 0, 0, 0, s_reference_width, s_reference_height,
10511 s_reference_depth, m_reference_compressed_3D_format,
10512 m_reference_compressed_3D_size, m_reference_compressed_3D);
10513 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage3D",
10514 "texture is not the name of an existing texture object.");
10517 /* Check that INVALID_ENUM is generated by CompressedTextureSubImage3D if
10518 internalformat is of the generic compressed internal formats:
10519 COMPRESSED_RED, COMPRESSED_RG, COMPRESSED_RGB, COMPRESSED_RGBA.
10520 COMPRESSED_SRGB, or COMPRESSED_SRGB_ALPHA. */
10522 gl.compressedTextureSubImage3D(m_to_3D_compressed, 0, 0, 0, 0, s_reference_width, s_reference_height,
10523 s_reference_depth, GL_COMPRESSED_RG, m_reference_compressed_3D_size,
10524 m_reference_compressed_3D);
10525 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glCompressedTextureSubImage3D",
10526 "internalformat is of the generic compressed internal formats: COMPRESSED_RED, "
10527 "COMPRESSED_RG, COMPRESSED_RGB, COMPRESSED_RGBA. COMPRESSED_SRGB, or "
10528 "COMPRESSED_SRGB_ALPHA.");
10531 /* Check that INVALID_OPERATION is generated if format does not match the
10532 internal format of the texture image being modified, since these
10533 commands do not provide for image format conversion. */
10535 gl.compressedTextureSubImage3D(m_to_3D_compressed, 0, 0, 0, 0, s_reference_width, s_reference_height,
10536 s_reference_depth, m_not_matching_compressed_3D_format,
10537 m_not_matching_compressed_3D_size, m_reference_compressed_3D);
10538 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage3D",
10539 "format does not match the internal format of the texture image being modified, "
10540 "since these commands do not provide for image format conversion.");
10543 /* Check that INVALID_VALUE is generated by CompressedTextureSubImage3D if
10544 imageSize is not consistent with the format, dimensions, and contents of
10545 the specified compressed image data. */
10547 gl.compressedTextureSubImage3D(m_to_3D_compressed, 0, 0, 0, 0, s_reference_width, s_reference_height,
10548 s_reference_depth, m_reference_compressed_3D_format,
10549 m_reference_compressed_3D_size - 1, m_reference_compressed_3D);
10550 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCompressedTextureSubImage3D",
10551 "imageSize is not consistent with the format, dimensions, and contents of the "
10552 "specified compressed image data.");
10555 /* Check that INVALID_OPERATION is generated by CompressedTextureSubImage3D
10556 if a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER
10557 target and the buffer object's data store is currently mapped. */
10559 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
10560 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10562 gl.mapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_READ_WRITE);
10564 if (GL_NO_ERROR == gl.getError())
10566 gl.compressedTextureSubImage3D(m_to_3D_compressed, 0, 0, 0, 0, s_reference_width, s_reference_height,
10567 s_reference_depth, m_reference_compressed_3D_format,
10568 m_reference_compressed_3D_size, NULL);
10569 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage3D",
10570 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target "
10571 "and the buffer object's data store is currently mapped.");
10573 gl.unmapBuffer(GL_PIXEL_UNPACK_BUFFER);
10574 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10576 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10577 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10581 /* Check that INVALID_OPERATION is generated by CompressedTextureSubImage3D
10582 if a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER
10583 target and the data would be unpacked from the buffer object such that
10584 the memory reads required would exceed the data store size. */
10586 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, m_bo);
10587 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10589 gl.compressedTextureSubImage3D(m_to_3D_compressed, 0, 0, 0, 0, s_reference_width, s_reference_height,
10590 s_reference_depth, m_reference_compressed_3D_format,
10591 m_reference_compressed_3D_size, (glw::GLubyte*)NULL + s_reference_size * 2);
10592 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage3D",
10593 "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and "
10594 "the buffer object's data store is currently mapped.");
10596 gl.bindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
10597 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
10604 /** @brief Clean GL objects, test variables and GL errors.
10606 void SubImageErrorsTest::Clean()
10608 /* Shortcut for GL functionality. */
10609 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
10614 gl.deleteTextures(1, &m_to_1D_empty);
10621 gl.deleteTextures(1, &m_to_2D_empty);
10628 gl.deleteTextures(1, &m_to_3D_empty);
10635 gl.deleteTextures(1, &m_to_1D);
10642 gl.deleteTextures(1, &m_to_2D);
10649 gl.deleteTextures(1, &m_to_3D);
10654 if (m_to_1D_compressed)
10656 gl.deleteTextures(1, &m_to_1D_compressed);
10658 m_to_1D_compressed = 0;
10661 if (m_to_2D_compressed)
10663 gl.deleteTextures(1, &m_to_2D_compressed);
10665 m_to_2D_compressed = 0;
10668 if (m_to_3D_compressed)
10670 gl.deleteTextures(1, &m_to_3D_compressed);
10672 m_to_3D_compressed = 0;
10675 if (m_to_rectangle_compressed)
10677 gl.deleteTextures(1, &m_to_rectangle_compressed);
10679 m_to_rectangle_compressed = 0;
10684 gl.deleteBuffers(1, &m_bo);
10690 m_format_invalid = 0;
10691 m_type_invalid = 0;
10692 m_max_texture_size = 1;
10694 if (DE_NULL != m_reference_compressed_1D)
10696 delete[] m_reference_compressed_1D;
10698 m_reference_compressed_1D = NULL;
10701 if (DE_NULL != m_reference_compressed_2D)
10703 delete[] m_reference_compressed_2D;
10705 m_reference_compressed_2D = NULL;
10708 if (DE_NULL != m_reference_compressed_3D)
10710 delete[] m_reference_compressed_3D;
10712 m_reference_compressed_3D = NULL;
10715 if (DE_NULL != m_reference_compressed_rectangle)
10717 delete[] m_reference_compressed_rectangle;
10719 m_reference_compressed_rectangle = NULL;
10722 m_reference_compressed_1D_format = 0;
10723 m_reference_compressed_2D_format = 0;
10724 m_reference_compressed_3D_format = 0;
10725 m_reference_compressed_rectangle_format = 0;
10726 m_reference_compressed_1D_size = 0;
10727 m_reference_compressed_2D_size = 0;
10728 m_reference_compressed_3D_size = 0;
10729 m_reference_compressed_rectangle_size = 0;
10730 m_not_matching_compressed_1D_format = 0;
10731 m_not_matching_compressed_1D_size = 0;
10732 m_not_matching_compressed_2D_format = 0;
10733 m_not_matching_compressed_2D_size = 0;
10734 m_not_matching_compressed_3D_format = 0;
10735 m_not_matching_compressed_3D_size = 0;
10737 while (GL_NO_ERROR != gl.getError())
10741 /** Reference data */
10742 const glw::GLushort SubImageErrorsTest::s_reference[] = {
10743 0x0, 0x0, 0x0, 0xff, 0x7f, 0x7f, 0x7f, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff,
10744 0x88, 0x0, 0x15, 0xff, 0xed, 0x1c, 0x24, 0xff, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x0, 0xff,
10745 0xc8, 0xbf, 0xe7, 0xff, 0x70, 0x92, 0xbe, 0xff, 0x99, 0xd9, 0xea, 0xff, 0xb5, 0xe6, 0x1d, 0xff,
10746 0xa3, 0x49, 0xa4, 0xff, 0x3f, 0x48, 0xcc, 0xff, 0x0, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0xff,
10748 0x0, 0x0, 0x0, 0xff, 0x7f, 0x7f, 0x7f, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff,
10749 0x88, 0x0, 0x15, 0xff, 0xed, 0x1c, 0x24, 0xff, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x0, 0xff,
10750 0xc8, 0xbf, 0xe7, 0xff, 0x70, 0x92, 0xbe, 0xff, 0x99, 0xd9, 0xea, 0xff, 0xb5, 0xe6, 0x1d, 0xff,
10751 0xa3, 0x49, 0xa4, 0xff, 0x3f, 0x48, 0xcc, 0xff, 0x0, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0xff,
10753 0x0, 0x0, 0x0, 0xff, 0x7f, 0x7f, 0x7f, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff,
10754 0x88, 0x0, 0x15, 0xff, 0xed, 0x1c, 0x24, 0xff, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x0, 0xff,
10755 0xc8, 0xbf, 0xe7, 0xff, 0x70, 0x92, 0xbe, 0xff, 0x99, 0xd9, 0xea, 0xff, 0xb5, 0xe6, 0x1d, 0xff,
10756 0xa3, 0x49, 0xa4, 0xff, 0x3f, 0x48, 0xcc, 0xff, 0x0, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0xff,
10758 0x0, 0x0, 0x0, 0xff, 0x7f, 0x7f, 0x7f, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff,
10759 0x88, 0x0, 0x15, 0xff, 0xed, 0x1c, 0x24, 0xff, 0xff, 0x7f, 0x27, 0xff, 0xff, 0xf2, 0x0, 0xff,
10760 0xc8, 0xbf, 0xe7, 0xff, 0x70, 0x92, 0xbe, 0xff, 0x99, 0xd9, 0xea, 0xff, 0xb5, 0xe6, 0x1d, 0xff,
10761 0xa3, 0x49, 0xa4, 0xff, 0x3f, 0x48, 0xcc, 0xff, 0x0, 0xa2, 0xe8, 0xff, 0x22, 0xb1, 0x4c, 0xff
10764 /** Reference data parameters. */
10765 const glw::GLuint SubImageErrorsTest::s_reference_size = sizeof(s_reference);
10766 const glw::GLuint SubImageErrorsTest::s_reference_width = 4;
10767 const glw::GLuint SubImageErrorsTest::s_reference_height = 4;
10768 const glw::GLuint SubImageErrorsTest::s_reference_depth = 4;
10769 const glw::GLenum SubImageErrorsTest::s_reference_internalformat = GL_RG8;
10770 const glw::GLenum SubImageErrorsTest::s_reference_internalformat_compressed = GL_COMPRESSED_RG;
10771 const glw::GLenum SubImageErrorsTest::s_reference_format = GL_RG; /* !Must not be a RGB, RGBA, or BGRA */
10772 const glw::GLenum SubImageErrorsTest::s_reference_type = GL_UNSIGNED_SHORT;
10774 /******************************** Copy Errors Test Implementation ********************************/
10776 /** @brief Copy Errors Test constructor.
10778 * @param [in] context OpenGL context.
10780 CopyErrorsTest::CopyErrorsTest(deqp::Context& context)
10781 : deqp::TestCase(context, "textures_copy_errors", "Texture Copy Errors Test")
10784 , m_fbo_incomplete(0)
10792 /* Intentionally left blank. */
10795 /** @brief Iterate Copy Errors Test cases.
10797 * @return Iteration result.
10799 tcu::TestNode::IterateResult CopyErrorsTest::iterate()
10801 /* Get context setup. */
10802 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
10803 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
10805 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
10807 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
10812 /* Running tests. */
10814 bool is_error = false;
10833 /* Result's setup. */
10836 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
10842 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
10846 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
10853 /** @brief Prepare test's objects and values.
10855 void CopyErrorsTest::Prepare()
10857 /* Shortcut for GL functionality. */
10858 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
10860 /* Auxiliary objects setup. */
10863 gl.genFramebuffers(1, &m_fbo);
10864 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
10866 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
10867 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
10869 gl.createTextures(GL_TEXTURE_2D, 1, &m_to_src);
10870 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
10872 gl.textureStorage2D(m_to_src, 1, s_internalformat, s_width, s_height);
10873 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage2D has failed");
10875 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_to_src, 0);
10876 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferTexture1D call failed.");
10878 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
10883 gl.viewport(0, 0, s_width, s_height);
10884 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
10886 gl.clear(GL_COLOR_BUFFER_BIT);
10887 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear call failed.");
10889 /* Framebuffer Multisample. */
10890 gl.genFramebuffers(1, &m_fbo_ms);
10891 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
10893 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_ms);
10894 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
10896 gl.createTextures(GL_TEXTURE_2D_MULTISAMPLE, 1, &m_to_src_ms);
10897 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
10899 gl.textureStorage2DMultisample(m_to_src_ms, 1, s_internalformat, s_width, s_height, false);
10900 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage2DMultisample has failed");
10902 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, m_to_src_ms, 0);
10903 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferTexture1D call failed.");
10905 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
10910 gl.viewport(0, 0, s_width, s_height);
10911 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
10913 gl.clear(GL_COLOR_BUFFER_BIT);
10914 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear call failed.");
10916 /* Framebuffer Incomplete. */
10917 gl.createFramebuffers(1, &m_fbo_incomplete);
10918 GLU_EXPECT_NO_ERROR(gl.getError(), "glcreateFramebuffers call failed.");
10921 gl.createTextures(GL_TEXTURE_1D, 1, &m_to_1D_dst);
10922 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
10924 gl.textureStorage1D(m_to_1D_dst, 1, s_internalformat, s_width);
10925 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage2D has failed");
10928 gl.createTextures(GL_TEXTURE_2D, 1, &m_to_2D_dst);
10929 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
10931 gl.textureStorage2D(m_to_2D_dst, 1, s_internalformat, s_width, s_height);
10932 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage2D has failed");
10935 gl.createTextures(GL_TEXTURE_3D, 1, &m_to_3D_dst);
10936 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
10938 gl.textureStorage3D(m_to_3D_dst, 1, s_internalformat, s_width, s_height, s_depth);
10939 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage2D has failed");
10941 /* invalid texture object */
10942 while (gl.isTexture(++m_to_invalid))
10944 GLU_EXPECT_NO_ERROR(gl.getError(), "glIsTexture has failed");
10947 /** @brief Test (negative) of CopyTextureSubImage1D
10949 * @return Test result.
10951 bool CopyErrorsTest::Test1D()
10953 /* Shortcut for GL functionality. */
10954 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
10959 /* Bind framebuffer. */
10960 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_incomplete);
10961 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
10963 /* Check that INVALID_FRAMEBUFFER_OPERATION is generated by
10964 CopyTextureSubImage1D if the object bound to READ_FRAMEBUFFER_BINDING is
10965 not framebuffer complete. */
10967 gl.copyTextureSubImage1D(m_to_1D_dst, 0, 0, 0, 0, s_width);
10968 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_FRAMEBUFFER_OPERATION, "glCopyTextureSubImage1D",
10969 "the object bound to READ_FRAMEBUFFER_BINDING is not framebuffer complete.");
10972 /* Bind framebuffer. */
10973 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
10974 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
10976 gl.readBuffer(GL_COLOR_ATTACHMENT0);
10977 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
10979 /* Check that INVALID_OPERATION is generated by CopyTextureSubImage1D if
10980 texture is not the name of an existing texture object, or if the
10981 effective target of texture is not TEXTURE_1D. */
10983 gl.copyTextureSubImage1D(m_to_invalid, 0, 0, 0, 0, s_width);
10984 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage1D",
10985 "texture is not the name of an existing texture object.");
10987 gl.copyTextureSubImage1D(m_to_2D_dst, 0, 0, 0, 0, s_width);
10988 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage1D",
10989 "the effective target of texture is not TEXTURE_1D.");
10992 /* Check that INVALID_VALUE is generated by CopyTextureSubImage1D if level is less than 0. */
10994 gl.copyTextureSubImage1D(m_to_1D_dst, -1, 0, 0, 0, s_width);
10995 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage1D", "level is less than 0.");
10998 /* Check that INVALID_VALUE is generated by CopyTextureSubImage1D if
10999 xoffset<0, or (xoffset+width)>w, where w is the TEXTURE_WIDTH of the
11000 texture image being modified. */
11002 gl.copyTextureSubImage1D(m_to_1D_dst, 0, -1, 0, 0, s_width);
11003 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage1D", "xoffset<0.");
11005 gl.copyTextureSubImage1D(m_to_1D_dst, 0, 1, 0, 0, s_width);
11007 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage1D",
11008 "(xoffset+width)>w, where w is the TEXTURE_WIDTH of the texture image being modified.");
11011 /* Check that INVALID_OPERATION is generated by CopyTextureSubImage1D if
11012 the read buffer is NONE. */
11013 gl.readBuffer(GL_NONE);
11014 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11017 gl.copyTextureSubImage1D(m_to_1D_dst, 0, 0, 0, 0, s_width);
11019 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage1D", "the read buffer is NONE.");
11022 /* Bind multisample framebuffer. */
11023 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_ms);
11024 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11026 gl.readBuffer(GL_COLOR_ATTACHMENT0);
11027 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11029 /* Check that INVALID_OPERATION is generated by CopyTextureSubImage1D if
11030 the effective value of SAMPLE_BUFFERS for the read
11031 framebuffer is one. */
11033 gl.copyTextureSubImage1D(m_to_1D_dst, 0, 0, 0, 0, s_width);
11034 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage1D",
11035 "the effective value of SAMPLE_BUFFERS for the read framebuffer is one.");
11041 /** @brief Test (negative) of CopyTextureSubImage2D
11043 * @return Test result.
11045 bool CopyErrorsTest::Test2D()
11047 /* Shortcut for GL functionality. */
11048 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
11053 /* Bind framebuffer. */
11054 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_incomplete);
11055 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11057 /* Check that INVALID_FRAMEBUFFER_OPERATION is generated by
11058 CopyTextureSubImage2D if the object bound to READ_FRAMEBUFFER_BINDING is
11059 not framebuffer complete. */
11061 gl.copyTextureSubImage2D(m_to_2D_dst, 0, 0, 0, 0, 0, s_width, s_height);
11062 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_FRAMEBUFFER_OPERATION, "glCopyTextureSubImage2D",
11063 "the object bound to READ_FRAMEBUFFER_BINDING is not framebuffer complete.");
11066 /* Bind framebuffer. */
11067 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
11068 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11070 gl.readBuffer(GL_COLOR_ATTACHMENT0);
11071 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11073 /* Check that INVALID_OPERATION is generated by CopyTextureSubImage2D if
11074 texture is not the name of an existing texture object, or if the
11075 effective target of texture is not TEXTURE_2D. */
11077 gl.copyTextureSubImage2D(m_to_invalid, 0, 0, 0, 0, 0, s_width, s_height);
11078 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage2D",
11079 "texture is not the name of an existing texture object.");
11081 gl.copyTextureSubImage2D(m_to_1D_dst, 0, 0, 0, 0, 0, s_width, s_height);
11082 is_ok &= CheckErrorAndLog(
11083 m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage2D",
11084 "the effective target of does not correspond to one of the texture targets supported by the function..");
11087 /* Check that INVALID_VALUE is generated by CopyTextureSubImage2D if level is less than 0. */
11089 gl.copyTextureSubImage2D(m_to_2D_dst, -1, 0, 0, 0, 0, s_width, s_height);
11090 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage2D", "level is less than 0.");
11093 /* Check that INVALID_VALUE is generated by CopyTextureSubImage2D if
11094 xoffset<0, (xoffset+width)>w, yoffset<0, or (yoffset+height)>0, where w
11095 is the TEXTURE_WIDTH, h is the TEXTURE_HEIGHT and of the texture image
11098 gl.copyTextureSubImage2D(m_to_2D_dst, 0, -1, 0, 0, 0, s_width, s_height);
11099 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage2D", "xoffset<0.");
11101 gl.copyTextureSubImage2D(m_to_2D_dst, 0, 1, 0, 0, 0, s_width, s_height);
11103 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage2D",
11104 "(xoffset+width)>w, where w is the TEXTURE_WIDTH of the texture image being modified.");
11106 gl.copyTextureSubImage2D(m_to_2D_dst, 0, 0, -1, 0, 0, s_width, s_height);
11107 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage2D", "yoffset<0.");
11109 gl.copyTextureSubImage2D(m_to_2D_dst, 0, 0, 1, 0, 0, s_width, s_height);
11111 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage2D",
11112 "(yoffset+height)>h, where h is the TEXTURE_HEIGHT of the texture image being modified.");
11115 /* Check that INVALID_OPERATION is generated by CopyTextureSubImage2D if
11116 the read buffer is NONE. */
11117 gl.readBuffer(GL_NONE);
11118 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11121 gl.copyTextureSubImage2D(m_to_2D_dst, 0, 0, 0, 0, 0, s_width, s_height);
11123 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage2D", "the read buffer is NONE.");
11126 /* Bind multisample framebuffer. */
11127 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_ms);
11128 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11130 gl.readBuffer(GL_COLOR_ATTACHMENT0);
11131 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11133 /* Check that INVALID_OPERATION is generated by CopyTextureSubImage2D if
11134 the effective value of SAMPLE_BUFFERS for the read
11135 framebuffer is one. */
11137 gl.copyTextureSubImage2D(m_to_2D_dst, 0, 0, 0, 0, 0, s_width, s_height);
11138 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage2D",
11139 "the effective value of SAMPLE_BUFFERS for the read framebuffer is one.");
11145 /** @brief Test (negative) of CopyTextureSubImage3D
11147 * @return Test result.
11149 bool CopyErrorsTest::Test3D()
11151 /* Shortcut for GL functionality. */
11152 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
11157 /* Bind framebuffer. */
11158 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_incomplete);
11159 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11161 /* Check that INVALID_FRAMEBUFFER_OPERATION is generated by
11162 CopyTextureSubImage3D if the object bound to READ_FRAMEBUFFER_BINDING is
11163 not framebuffer complete. */
11165 gl.copyTextureSubImage3D(m_to_3D_dst, 0, 0, 0, 0, 0, 0, s_width, s_height);
11166 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_FRAMEBUFFER_OPERATION, "glCopyTextureSubImage3D",
11167 "the object bound to READ_FRAMEBUFFER_BINDING is not framebuffer complete.");
11170 /* Bind framebuffer. */
11171 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
11172 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11174 gl.readBuffer(GL_COLOR_ATTACHMENT0);
11175 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11177 /* Check that INVALID_OPERATION is generated by CopyTextureSubImage3D if
11178 texture is not the name of an existing texture object, or if the
11179 effective target of texture is not supported by the function. */
11181 gl.copyTextureSubImage3D(m_to_invalid, 0, 0, 0, 0, 0, 0, s_width, s_height);
11182 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage3D",
11183 "texture is not the name of an existing texture object.");
11185 gl.copyTextureSubImage3D(m_to_1D_dst, 0, 0, 0, 0, 0, 0, s_width, s_height);
11186 is_ok &= CheckErrorAndLog(
11187 m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage3D",
11188 "the effective target of does not correspond to one of the texture targets supported by the function..");
11191 /* Check that INVALID_VALUE is generated by CopyTextureSubImage3D if level is less than 0. */
11193 gl.copyTextureSubImage3D(m_to_3D_dst, -1, 0, 0, 0, 0, 0, s_width, s_height);
11194 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage3D", "level is less than 0.");
11197 /* Check that INVALID_VALUE is generated by CopyTextureSubImage3D if
11198 xoffset<0, (xoffset+width)>w, yoffset<0, (yoffset+height)>h, zoffset<0,
11199 or (zoffset+1)>d, where w is the TEXTURE_WIDTH, h is the TEXTURE_HEIGHT,
11200 d is the TEXTURE_DEPTH and of the texture image being modified. Note
11201 that w, h, and d include twice the border width. */
11203 gl.copyTextureSubImage3D(m_to_3D_dst, 0, -1, 0, 0, 0, 0, s_width, s_height);
11204 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage3D", "xoffset<0.");
11206 gl.copyTextureSubImage3D(m_to_3D_dst, 0, 1, 0, 0, 0, 0, s_width, s_height);
11208 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage3D",
11209 "(xoffset+width)>w, where w is the TEXTURE_WIDTH of the texture image being modified.");
11211 gl.copyTextureSubImage3D(m_to_3D_dst, 0, 0, -1, 0, 0, 0, s_width, s_height);
11212 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage3D", "yoffset<0.");
11214 gl.copyTextureSubImage3D(m_to_3D_dst, 0, 0, 1, 0, 0, 0, s_width, s_height);
11216 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage3D",
11217 "(yoffset+height)>h, where h is the TEXTURE_HEIGHT of the texture image being modified.");
11219 gl.copyTextureSubImage3D(m_to_3D_dst, 0, 0, 0, -1, 0, 0, s_width, s_height);
11220 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage3D", "zoffset<0.");
11222 gl.copyTextureSubImage3D(m_to_3D_dst, 0, 0, 0, s_depth + 1, 0, 0, s_width, s_height);
11223 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glCopyTextureSubImage3D",
11224 "(zoffset+1)>d, where d is the TEXTURE_DEPTH of the texture image being modified.");
11227 /* Check that INVALID_OPERATION is generated by CopyTextureSubImage3D if
11228 the read buffer is NONE. */
11229 gl.readBuffer(GL_NONE);
11230 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11233 gl.copyTextureSubImage3D(m_to_3D_dst, 0, 0, 0, 0, 0, 0, s_width, s_height);
11235 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage3D", "the read buffer is NONE.");
11238 /* Bind multisample framebuffer. */
11239 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_ms);
11240 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11242 gl.readBuffer(GL_COLOR_ATTACHMENT0);
11243 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
11245 /* Check that INVALID_OPERATION is generated by CopyTextureSubImage3D if
11246 the effective value of SAMPLE_BUFFERS for the read
11247 framebuffer is one. */
11249 gl.copyTextureSubImage3D(m_to_3D_dst, 0, 0, 0, 0, 0, 0, s_width, s_height);
11250 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCopyTextureSubImage3D",
11251 "the effective value of SAMPLE_BUFFERS for the read framebuffer is one.");
11257 /** @brief Clean GL objects, test variables and GL errors.
11259 void CopyErrorsTest::Clean()
11261 /* Shortcut for GL functionality. */
11262 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
11267 gl.deleteFramebuffers(1, &m_fbo);
11274 gl.deleteFramebuffers(1, &m_fbo_ms);
11279 if (m_fbo_incomplete)
11281 gl.deleteFramebuffers(1, &m_fbo_incomplete);
11283 m_fbo_incomplete = 0;
11288 gl.deleteTextures(1, &m_to_src);
11295 gl.deleteTextures(1, &m_to_src_ms);
11302 gl.deleteTextures(1, &m_to_1D_dst);
11309 gl.deleteTextures(1, &m_to_2D_dst);
11316 gl.deleteTextures(1, &m_to_3D_dst);
11323 while (GL_NO_ERROR != gl.getError())
11327 /* Test's parameters. */
11328 const glw::GLuint CopyErrorsTest::s_width = 4;
11329 const glw::GLuint CopyErrorsTest::s_height = 4;
11330 const glw::GLuint CopyErrorsTest::s_depth = 4;
11331 const glw::GLuint CopyErrorsTest::s_internalformat = GL_RGBA8;
11333 /******************************** Parameter Setup Errors Test Implementation ********************************/
11335 /** @brief Parameter Setup Errors Test constructor.
11337 * @param [in] context OpenGL context.
11339 ParameterSetupErrorsTest::ParameterSetupErrorsTest(deqp::Context& context)
11340 : deqp::TestCase(context, "textures_parameter_setup_errors", "Texture Parameter Setup Errors Test")
11343 , m_to_rectangle(0)
11345 , m_pname_invalid(0)
11346 , m_depth_stencil_mode_invalid(0)
11348 /* Intentionally left blank. */
11351 /** @brief Iterate Parameter Setup Errors Test cases.
11353 * @return Iteration result.
11355 tcu::TestNode::IterateResult ParameterSetupErrorsTest::iterate()
11357 /* Get context setup. */
11358 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
11359 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
11361 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
11363 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
11368 /* Running tests. */
11370 bool is_error = false;
11380 is_ok &= TestIiv();
11381 is_ok &= TestIuiv();
11392 /* Result's setup. */
11395 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
11401 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
11405 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
11412 /** @brief Test's preparations.
11414 void ParameterSetupErrorsTest::Prepare()
11416 /* Shortcut for GL functionality. */
11417 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
11419 /* Auxiliary objects setup. */
11422 gl.createTextures(GL_TEXTURE_2D, 1, &m_to_2D);
11423 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
11426 gl.createTextures(GL_TEXTURE_2D_MULTISAMPLE, 1, &m_to_2D_ms);
11427 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
11430 gl.createTextures(GL_TEXTURE_RECTANGLE, 1, &m_to_rectangle);
11431 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateTextures has failed");
11433 /* Invalid texture object. */
11434 while (gl.isTexture(++m_to_invalid))
11436 GLU_EXPECT_NO_ERROR(gl.getError(), "glIsTexture has failed");
11438 /* Invalid parameter name. */
11439 glw::GLenum all_pnames[] = { GL_DEPTH_STENCIL_TEXTURE_MODE,
11440 GL_TEXTURE_BASE_LEVEL,
11441 GL_TEXTURE_COMPARE_FUNC,
11442 GL_TEXTURE_COMPARE_MODE,
11443 GL_TEXTURE_LOD_BIAS,
11444 GL_TEXTURE_MIN_FILTER,
11445 GL_TEXTURE_MAG_FILTER,
11446 GL_TEXTURE_MIN_LOD,
11447 GL_TEXTURE_MAX_LOD,
11448 GL_TEXTURE_MAX_LEVEL,
11449 GL_TEXTURE_SWIZZLE_R,
11450 GL_TEXTURE_SWIZZLE_G,
11451 GL_TEXTURE_SWIZZLE_B,
11452 GL_TEXTURE_SWIZZLE_A,
11456 GL_TEXTURE_BORDER_COLOR,
11457 GL_TEXTURE_SWIZZLE_RGBA };
11458 glw::GLuint all_pnames_count = sizeof(all_pnames) / sizeof(all_pnames[0]);
11460 bool is_valid = true;
11467 for (glw::GLuint i = 0; i < all_pnames_count; ++i)
11469 if (all_pnames[i] == m_pname_invalid)
11478 /* Invalid depth stencil mode name. */
11479 glw::GLenum all_depth_stencil_modes[] = { GL_DEPTH_COMPONENT, GL_STENCIL_INDEX };
11480 glw::GLuint all_depth_stencil_modes_count = sizeof(all_depth_stencil_modes) / sizeof(all_depth_stencil_modes[0]);
11487 ++m_depth_stencil_mode_invalid;
11489 for (glw::GLuint i = 0; i < all_depth_stencil_modes_count; ++i)
11491 if (all_depth_stencil_modes[i] == m_depth_stencil_mode_invalid)
11501 /** @brief Test (negative) of TextureParameterf
11503 * @return Test result.
11505 bool ParameterSetupErrorsTest::Testf()
11507 /* Shortcut for GL functionality. */
11508 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
11513 /* Check that INVALID_ENUM is generated by TextureParameter* if pname is
11514 not one of the accepted defined values. */
11516 gl.textureParameterf(m_to_2D, m_pname_invalid, 1.f);
11518 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterf",
11519 "pname is not one of the accepted defined values.");
11522 /* Check that INVALID_ENUM is generated by TextureParameter* if params
11523 should have a defined constant value (based on the value of pname) and
11526 gl.textureParameterf(m_to_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, (glw::GLfloat)m_depth_stencil_mode_invalid);
11529 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterf",
11530 "params should have a defined constant value (based on the value of pname) and does not.");
11532 /* Check that INVALID_ENUM is generated if TextureParameter{if} is called
11533 for a non-scalar parameter (pname TEXTURE_BORDER_COLOR or
11534 TEXTURE_SWIZZLE_RGBA). */
11536 gl.textureParameterf(m_to_2D, GL_TEXTURE_BORDER_COLOR, 1.f);
11539 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterf",
11540 "called for a non-scalar parameter (pname TEXTURE_BORDER_COLOR or TEXTURE_SWIZZLE_RGBA).");
11543 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11544 effective target is either TEXTURE_2D_MULTISAMPLE or
11545 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states. */
11547 gl.textureParameterf(m_to_2D_ms, GL_TEXTURE_LOD_BIAS, 1.f);
11549 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterf",
11550 "the effective target is either TEXTURE_2D_MULTISAMPLE or "
11551 "TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states.");
11554 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11555 effective target is TEXTURE_RECTANGLE and either of pnames
11556 TEXTURE_WRAP_S or TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE,
11557 MIRRORED_REPEAT or REPEAT. */
11559 gl.textureParameterf(m_to_rectangle, GL_TEXTURE_WRAP_S, GL_MIRROR_CLAMP_TO_EDGE);
11561 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterf",
11562 "the effective target is TEXTURE_RECTANGLE and either of pnames TEXTURE_WRAP_S or "
11563 "TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE, MIRRORED_REPEAT or REPEAT.");
11566 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11567 effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is
11568 set to a value other than NEAREST or LINEAR (no mipmap filtering is
11571 gl.textureParameterf(m_to_rectangle, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
11573 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterf",
11574 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is set to a "
11575 "value other than NEAREST or LINEAR (no mipmap filtering is permitted).");
11578 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
11579 effective target is either TEXTURE_2D_MULTISAMPLE or
11580 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname TEXTURE_BASE_LEVEL is set to a
11581 value other than zero. */
11583 gl.textureParameterf(m_to_2D_ms, GL_TEXTURE_BASE_LEVEL, 1.f);
11586 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterf",
11587 "the effective target is either TEXTURE_2D_MULTISAMPLE or TEXTURE_2D_MULTISAMPLE_ARRAY, "
11588 "and pname TEXTURE_BASE_LEVEL is set to a value other than zero.");
11591 /* Check that INVALID_OPERATION is generated by TextureParameter* if
11592 texture is not the name of an existing texture object. */
11594 gl.textureParameterf(m_to_invalid, GL_TEXTURE_LOD_BIAS, 1.f);
11596 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterf",
11597 "texture is not the name of an existing texture object.");
11600 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
11601 effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is
11602 set to any value other than zero. */
11604 gl.textureParameterf(m_to_rectangle, GL_TEXTURE_BASE_LEVEL, 1.f);
11606 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterf",
11607 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is set to "
11608 "any value other than zero. ");
11611 /* Check that INVALID_VALUE is generated by TextureParameter* if pname is
11612 TEXTURE_BASE_LEVEL or TEXTURE_MAX_LEVEL, and param or params is
11615 gl.textureParameterf(m_to_2D, GL_TEXTURE_BASE_LEVEL, -1.f);
11617 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureParameterf",
11618 "pname is TEXTURE_BASE_LEVEL and param is negative.");
11620 gl.textureParameterf(m_to_2D, GL_TEXTURE_MAX_LEVEL, -1.f);
11622 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureParameterf",
11623 "pname is TEXTURE_MAX_LEVEL and param is negative.");
11629 /** @brief Test (negative) of TextureParameteri
11631 * @return Test result.
11633 bool ParameterSetupErrorsTest::Testi()
11635 /* Shortcut for GL functionality. */
11636 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
11641 /* Check that INVALID_ENUM is generated by TextureParameter* if pname is
11642 not one of the accepted defined values. */
11644 gl.textureParameteri(m_to_2D, m_pname_invalid, 1);
11646 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteri",
11647 "pname is not one of the accepted defined values.");
11650 /* Check that INVALID_ENUM is generated by TextureParameter* if params
11651 should have a defined constant value (based on the value of pname) and
11654 gl.textureParameteri(m_to_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, m_depth_stencil_mode_invalid);
11657 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteri",
11658 "params should have a defined constant value (based on the value of pname) and does not.");
11660 /* Check that INVALID_ENUM is generated if TextureParameter{if} is called
11661 for a non-scalar parameter (pname TEXTURE_BORDER_COLOR or
11662 TEXTURE_SWIZZLE_RGBA). */
11664 gl.textureParameteri(m_to_2D, GL_TEXTURE_BORDER_COLOR, 1);
11667 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteri",
11668 "called for a non-scalar parameter (pname TEXTURE_BORDER_COLOR or TEXTURE_SWIZZLE_RGBA).");
11671 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11672 effective target is either TEXTURE_2D_MULTISAMPLE or
11673 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states. */
11675 gl.textureParameteri(m_to_2D_ms, GL_TEXTURE_LOD_BIAS, 1);
11677 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteri",
11678 "the effective target is either TEXTURE_2D_MULTISAMPLE or "
11679 "TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states.");
11682 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11683 effective target is TEXTURE_RECTANGLE and either of pnames
11684 TEXTURE_WRAP_S or TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE,
11685 MIRRORED_REPEAT or REPEAT. */
11687 gl.textureParameteri(m_to_rectangle, GL_TEXTURE_WRAP_S, GL_MIRROR_CLAMP_TO_EDGE);
11689 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteri",
11690 "the effective target is TEXTURE_RECTANGLE and either of pnames TEXTURE_WRAP_S or "
11691 "TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE, MIRRORED_REPEAT or REPEAT.");
11694 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11695 effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is
11696 set to a value other than NEAREST or LINEAR (no mipmap filtering is
11699 gl.textureParameteri(m_to_rectangle, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
11701 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteri",
11702 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is set to a "
11703 "value other than NEAREST or LINEAR (no mipmap filtering is permitted).");
11706 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
11707 effective target is either TEXTURE_2D_MULTISAMPLE or
11708 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname TEXTURE_BASE_LEVEL is set to a
11709 value other than zero. */
11711 gl.textureParameteri(m_to_2D_ms, GL_TEXTURE_BASE_LEVEL, 1);
11714 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameteri",
11715 "the effective target is either TEXTURE_2D_MULTISAMPLE or TEXTURE_2D_MULTISAMPLE_ARRAY, "
11716 "and pname TEXTURE_BASE_LEVEL is set to a value other than zero.");
11719 /* Check that INVALID_OPERATION is generated by TextureParameter* if
11720 texture is not the name of an existing texture object. */
11722 gl.textureParameteri(m_to_invalid, GL_TEXTURE_LOD_BIAS, 1);
11724 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameteri",
11725 "texture is not the name of an existing texture object.");
11728 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
11729 effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is
11730 set to any value other than zero. */
11732 gl.textureParameteri(m_to_rectangle, GL_TEXTURE_BASE_LEVEL, 1);
11734 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameteri",
11735 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is set to "
11736 "any value other than zero. ");
11739 /* Check that INVALID_VALUE is generated by TextureParameter* if pname is
11740 TEXTURE_BASE_LEVEL or TEXTURE_MAX_LEVEL, and param or params is
11743 gl.textureParameteri(m_to_2D, GL_TEXTURE_BASE_LEVEL, -1);
11745 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureParameteri",
11746 "pname is TEXTURE_BASE_LEVEL and param is negative.");
11748 gl.textureParameteri(m_to_2D, GL_TEXTURE_MAX_LEVEL, -1);
11750 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureParameteri",
11751 "pname is TEXTURE_MAX_LEVEL and param is negative.");
11757 /** @brief Test (negative) of TextureParameterfv
11759 * @return Test result.
11761 bool ParameterSetupErrorsTest::Testfv()
11763 /* Shortcut for GL functionality. */
11764 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
11769 glw::GLfloat one = 1.f;
11770 glw::GLfloat minus_one = -1.f;
11771 glw::GLfloat depth_stencil_mode_invalid = (glw::GLfloat)m_depth_stencil_mode_invalid;
11772 glw::GLfloat wrap_invalid = (glw::GLfloat)GL_MIRROR_CLAMP_TO_EDGE;
11773 glw::GLfloat min_filter_invalid = (glw::GLfloat)GL_NEAREST_MIPMAP_NEAREST;
11775 /* Check that INVALID_ENUM is generated by TextureParameter* if pname is
11776 not one of the accepted defined values. */
11778 gl.textureParameterfv(m_to_2D, m_pname_invalid, &one);
11780 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterfv",
11781 "pname is not one of the accepted defined values.");
11784 /* Check that INVALID_ENUM is generated by TextureParameter* if params
11785 should have a defined constant value (based on the value of pname) and
11788 gl.textureParameterfv(m_to_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, &depth_stencil_mode_invalid);
11791 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterfv",
11792 "params should have a defined constant value (based on the value of pname) and does not.");
11795 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11796 effective target is either TEXTURE_2D_MULTISAMPLE or
11797 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states. */
11799 gl.textureParameterfv(m_to_2D_ms, GL_TEXTURE_LOD_BIAS, &one);
11801 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterfv",
11802 "the effective target is either TEXTURE_2D_MULTISAMPLE or "
11803 "TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states.");
11806 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11807 effective target is TEXTURE_RECTANGLE and either of pnames
11808 TEXTURE_WRAP_S or TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE,
11809 MIRRORED_REPEAT or REPEAT. */
11811 gl.textureParameterfv(m_to_rectangle, GL_TEXTURE_WRAP_S, &wrap_invalid);
11813 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterfv",
11814 "the effective target is TEXTURE_RECTANGLE and either of pnames TEXTURE_WRAP_S or "
11815 "TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE, MIRRORED_REPEAT or REPEAT.");
11818 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11819 effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is
11820 set to a value other than NEAREST or LINEAR (no mipmap filtering is
11823 gl.textureParameterfv(m_to_rectangle, GL_TEXTURE_MIN_FILTER, &min_filter_invalid);
11825 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterfv",
11826 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is set to a "
11827 "value other than NEAREST or LINEAR (no mipmap filtering is permitted).");
11830 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
11831 effective target is either TEXTURE_2D_MULTISAMPLE or
11832 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname TEXTURE_BASE_LEVEL is set to a
11833 value other than zero. */
11835 gl.textureParameterfv(m_to_2D_ms, GL_TEXTURE_BASE_LEVEL, &one);
11838 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterfv",
11839 "the effective target is either TEXTURE_2D_MULTISAMPLE or TEXTURE_2D_MULTISAMPLE_ARRAY, "
11840 "and pname TEXTURE_BASE_LEVEL is set to a value other than zero.");
11843 /* Check that INVALID_OPERATION is generated by TextureParameter* if
11844 texture is not the name of an existing texture object. */
11846 gl.textureParameterfv(m_to_invalid, GL_TEXTURE_LOD_BIAS, &one);
11848 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterfv",
11849 "texture is not the name of an existing texture object.");
11852 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
11853 effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is
11854 set to any value other than zero. */
11856 gl.textureParameterfv(m_to_rectangle, GL_TEXTURE_BASE_LEVEL, &one);
11858 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterfv",
11859 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is set to "
11860 "any value other than zero. ");
11863 /* Check that INVALID_VALUE is generated by TextureParameter* if pname is
11864 TEXTURE_BASE_LEVEL or TEXTURE_MAX_LEVEL, and param or params is
11867 gl.textureParameterfv(m_to_2D, GL_TEXTURE_BASE_LEVEL, &minus_one);
11869 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureParameterfv",
11870 "pname is TEXTURE_BASE_LEVEL and param is negative.");
11872 gl.textureParameterfv(m_to_2D, GL_TEXTURE_MAX_LEVEL, &minus_one);
11874 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureParameterfv",
11875 "pname is TEXTURE_MAX_LEVEL and param is negative.");
11881 /** @brief Test (negative) of TextureParameteriv
11883 * @return Test result.
11885 bool ParameterSetupErrorsTest::Testiv()
11887 /* Shortcut for GL functionality. */
11888 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
11893 glw::GLint one = 1;
11894 glw::GLint minus_one = -1;
11895 glw::GLint depth_stencil_mode_invalid = (glw::GLint)m_depth_stencil_mode_invalid;
11896 glw::GLint wrap_invalid = (glw::GLint)GL_MIRROR_CLAMP_TO_EDGE;
11897 glw::GLint min_filter_invalid = (glw::GLint)GL_NEAREST_MIPMAP_NEAREST;
11899 /* Check that INVALID_ENUM is generated by TextureParameter* if pname is
11900 not one of the accepted defined values. */
11902 gl.textureParameteriv(m_to_2D, m_pname_invalid, &one);
11904 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteriv",
11905 "pname is not one of the accepted defined values.");
11908 /* Check that INVALID_ENUM is generated by TextureParameter* if params
11909 should have a defined constant value (based on the value of pname) and
11912 gl.textureParameteriv(m_to_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, &depth_stencil_mode_invalid);
11915 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteriv",
11916 "params should have a defined constant value (based on the value of pname) and does not.");
11919 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11920 effective target is either TEXTURE_2D_MULTISAMPLE or
11921 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states. */
11923 gl.textureParameteriv(m_to_2D_ms, GL_TEXTURE_LOD_BIAS, &one);
11925 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteriv",
11926 "the effective target is either TEXTURE_2D_MULTISAMPLE or "
11927 "TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states.");
11930 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11931 effective target is TEXTURE_RECTANGLE and either of pnames
11932 TEXTURE_WRAP_S or TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE,
11933 MIRRORED_REPEAT or REPEAT. */
11935 gl.textureParameteriv(m_to_rectangle, GL_TEXTURE_WRAP_S, &wrap_invalid);
11937 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteriv",
11938 "the effective target is TEXTURE_RECTANGLE and either of pnames TEXTURE_WRAP_S or "
11939 "TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE, MIRRORED_REPEAT or REPEAT.");
11942 /* Check that INVALID_ENUM is generated by TextureParameter* if the
11943 effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is
11944 set to a value other than NEAREST or LINEAR (no mipmap filtering is
11947 gl.textureParameteriv(m_to_rectangle, GL_TEXTURE_MIN_FILTER, &min_filter_invalid);
11949 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameteriv",
11950 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is set to a "
11951 "value other than NEAREST or LINEAR (no mipmap filtering is permitted).");
11954 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
11955 effective target is either TEXTURE_2D_MULTISAMPLE or
11956 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname TEXTURE_BASE_LEVEL is set to a
11957 value other than zero. */
11959 gl.textureParameteriv(m_to_2D_ms, GL_TEXTURE_BASE_LEVEL, &one);
11962 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameteriv",
11963 "the effective target is either TEXTURE_2D_MULTISAMPLE or TEXTURE_2D_MULTISAMPLE_ARRAY, "
11964 "and pname TEXTURE_BASE_LEVEL is set to a value other than zero.");
11967 /* Check that INVALID_OPERATION is generated by TextureParameter* if
11968 texture is not the name of an existing texture object. */
11970 gl.textureParameteriv(m_to_invalid, GL_TEXTURE_LOD_BIAS, &one);
11972 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameteriv",
11973 "texture is not the name of an existing texture object.");
11976 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
11977 effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is
11978 set to any value other than zero. */
11980 gl.textureParameteriv(m_to_rectangle, GL_TEXTURE_BASE_LEVEL, &one);
11982 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameteriv",
11983 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is set to "
11984 "any value other than zero. ");
11987 /* Check that INVALID_VALUE is generated by TextureParameter* if pname is
11988 TEXTURE_BASE_LEVEL or TEXTURE_MAX_LEVEL, and param or params is
11991 gl.textureParameteriv(m_to_2D, GL_TEXTURE_BASE_LEVEL, &minus_one);
11993 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureParameteriv",
11994 "pname is TEXTURE_BASE_LEVEL and param is negative.");
11996 gl.textureParameteriv(m_to_2D, GL_TEXTURE_MAX_LEVEL, &minus_one);
11998 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureParameteriv",
11999 "pname is TEXTURE_MAX_LEVEL and param is negative.");
12005 /** @brief Test (negative) of TextureParameterIiv
12007 * @return Test result.
12009 bool ParameterSetupErrorsTest::TestIiv()
12011 /* Shortcut for GL functionality. */
12012 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
12017 glw::GLint one = 1;
12018 glw::GLint minus_one = -1;
12019 glw::GLint depth_stencil_mode_invalid = (glw::GLint)m_depth_stencil_mode_invalid;
12020 glw::GLint wrap_invalid = (glw::GLint)GL_MIRROR_CLAMP_TO_EDGE;
12021 glw::GLint min_filter_invalid = (glw::GLint)GL_NEAREST_MIPMAP_NEAREST;
12023 /* Check that INVALID_ENUM is generated by TextureParameter* if pname is
12024 not one of the accepted defined values. */
12026 gl.textureParameterIiv(m_to_2D, m_pname_invalid, &one);
12028 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterIiv",
12029 "pname is not one of the accepted defined values.");
12032 /* Check that INVALID_ENUM is generated by TextureParameter* if params
12033 should have a defined constant value (based on the value of pname) and
12036 gl.textureParameterIiv(m_to_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, &depth_stencil_mode_invalid);
12039 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterIiv",
12040 "params should have a defined constant value (based on the value of pname) and does not.");
12043 /* Check that INVALID_ENUM is generated by TextureParameter* if the
12044 effective target is either TEXTURE_2D_MULTISAMPLE or
12045 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states. */
12047 gl.textureParameterIiv(m_to_2D_ms, GL_TEXTURE_LOD_BIAS, &one);
12049 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterIiv",
12050 "the effective target is either TEXTURE_2D_MULTISAMPLE or "
12051 "TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states.");
12054 /* Check that INVALID_ENUM is generated by TextureParameter* if the
12055 effective target is TEXTURE_RECTANGLE and either of pnames
12056 TEXTURE_WRAP_S or TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE,
12057 MIRRORED_REPEAT or REPEAT. */
12059 gl.textureParameterIiv(m_to_rectangle, GL_TEXTURE_WRAP_S, &wrap_invalid);
12061 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterIiv",
12062 "the effective target is TEXTURE_RECTANGLE and either of pnames TEXTURE_WRAP_S or "
12063 "TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE, MIRRORED_REPEAT or REPEAT.");
12066 /* Check that INVALID_ENUM is generated by TextureParameter* if the
12067 effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is
12068 set to a value other than NEAREST or LINEAR (no mipmap filtering is
12071 gl.textureParameterIiv(m_to_rectangle, GL_TEXTURE_MIN_FILTER, &min_filter_invalid);
12073 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterIiv",
12074 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is set to a "
12075 "value other than NEAREST or LINEAR (no mipmap filtering is permitted).");
12078 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
12079 effective target is either TEXTURE_2D_MULTISAMPLE or
12080 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname TEXTURE_BASE_LEVEL is set to a
12081 value other than zero. */
12083 gl.textureParameterIiv(m_to_2D_ms, GL_TEXTURE_BASE_LEVEL, &one);
12086 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterIiv",
12087 "the effective target is either TEXTURE_2D_MULTISAMPLE or TEXTURE_2D_MULTISAMPLE_ARRAY, "
12088 "and pname TEXTURE_BASE_LEVEL is set to a value other than zero.");
12091 /* Check that INVALID_OPERATION is generated by TextureParameter* if
12092 texture is not the name of an existing texture object. */
12094 gl.textureParameterIiv(m_to_invalid, GL_TEXTURE_LOD_BIAS, &one);
12096 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterIiv",
12097 "texture is not the name of an existing texture object.");
12100 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
12101 effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is
12102 set to any value other than zero. */
12104 gl.textureParameterIiv(m_to_rectangle, GL_TEXTURE_BASE_LEVEL, &one);
12106 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterIiv",
12107 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is set to "
12108 "any value other than zero. ");
12111 /* Check that INVALID_VALUE is generated by TextureParameter* if pname is
12112 TEXTURE_BASE_LEVEL or TEXTURE_MAX_LEVEL, and param or params is
12115 gl.textureParameterIiv(m_to_2D, GL_TEXTURE_BASE_LEVEL, &minus_one);
12117 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureParameterIiv",
12118 "pname is TEXTURE_BASE_LEVEL and param is negative.");
12120 gl.textureParameterIiv(m_to_2D, GL_TEXTURE_MAX_LEVEL, &minus_one);
12122 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glTextureParameterIiv",
12123 "pname is TEXTURE_MAX_LEVEL and param is negative.");
12129 /** @brief Test (negative) of TextureParameterIuiv
12131 * @return Test result.
12133 bool ParameterSetupErrorsTest::TestIuiv()
12135 /* Shortcut for GL functionality. */
12136 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
12141 glw::GLuint one = 1;
12142 glw::GLuint depth_stencil_mode_invalid = (glw::GLint)m_depth_stencil_mode_invalid;
12143 glw::GLuint wrap_invalid = (glw::GLint)GL_MIRROR_CLAMP_TO_EDGE;
12144 glw::GLuint min_filter_invalid = (glw::GLint)GL_NEAREST_MIPMAP_NEAREST;
12146 /* Check that INVALID_ENUM is generated by TextureParameter* if pname is
12147 not one of the accepted defined values. */
12149 gl.textureParameterIuiv(m_to_2D, m_pname_invalid, &one);
12151 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterIuiv",
12152 "pname is not one of the accepted defined values.");
12155 /* Check that INVALID_ENUM is generated by TextureParameter* if params
12156 should have a defined constant value (based on the value of pname) and
12159 gl.textureParameterIuiv(m_to_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, &depth_stencil_mode_invalid);
12162 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterIuiv",
12163 "params should have a defined constant value (based on the value of pname) and does not.");
12166 /* Check that INVALID_ENUM is generated by TextureParameter* if the
12167 effective target is either TEXTURE_2D_MULTISAMPLE or
12168 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states. */
12170 gl.textureParameterIuiv(m_to_2D_ms, GL_TEXTURE_LOD_BIAS, &one);
12172 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterIuiv",
12173 "the effective target is either TEXTURE_2D_MULTISAMPLE or "
12174 "TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is any of the sampler states.");
12177 /* Check that INVALID_ENUM is generated by TextureParameter* if the
12178 effective target is TEXTURE_RECTANGLE and either of pnames
12179 TEXTURE_WRAP_S or TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE,
12180 MIRRORED_REPEAT or REPEAT. */
12182 gl.textureParameterIuiv(m_to_rectangle, GL_TEXTURE_WRAP_S, &wrap_invalid);
12184 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterIuiv",
12185 "the effective target is TEXTURE_RECTANGLE and either of pnames TEXTURE_WRAP_S or "
12186 "TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE, MIRRORED_REPEAT or REPEAT.");
12189 /* Check that INVALID_ENUM is generated by TextureParameter* if the
12190 effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is
12191 set to a value other than NEAREST or LINEAR (no mipmap filtering is
12194 gl.textureParameterIuiv(m_to_rectangle, GL_TEXTURE_MIN_FILTER, &min_filter_invalid);
12196 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glTextureParameterIuiv",
12197 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is set to a "
12198 "value other than NEAREST or LINEAR (no mipmap filtering is permitted).");
12201 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
12202 effective target is either TEXTURE_2D_MULTISAMPLE or
12203 TEXTURE_2D_MULTISAMPLE_ARRAY, and pname TEXTURE_BASE_LEVEL is set to a
12204 value other than zero. */
12206 gl.textureParameterIuiv(m_to_2D_ms, GL_TEXTURE_BASE_LEVEL, &one);
12209 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterIuiv",
12210 "the effective target is either TEXTURE_2D_MULTISAMPLE or TEXTURE_2D_MULTISAMPLE_ARRAY, "
12211 "and pname TEXTURE_BASE_LEVEL is set to a value other than zero.");
12214 /* Check that INVALID_OPERATION is generated by TextureParameter* if
12215 texture is not the name of an existing texture object. */
12217 gl.textureParameterIuiv(m_to_invalid, GL_TEXTURE_LOD_BIAS, &one);
12219 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterIuiv",
12220 "texture is not the name of an existing texture object.");
12223 /* Check that INVALID_OPERATION is generated by TextureParameter* if the
12224 effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is
12225 set to any value other than zero. */
12227 gl.textureParameterIuiv(m_to_rectangle, GL_TEXTURE_BASE_LEVEL, &one);
12229 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureParameterIuiv",
12230 "the effective target is TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is set to "
12231 "any value other than zero. ");
12237 /** @brief Clean GL objects, test variables and GL errors.
12239 void ParameterSetupErrorsTest::Clean()
12241 /* Shortcut for GL functionality. */
12242 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
12247 gl.deleteTextures(1, &m_to_2D);
12254 gl.deleteTextures(1, &m_to_2D_ms);
12259 if (m_to_rectangle)
12261 gl.deleteTextures(1, &m_to_rectangle);
12263 m_to_rectangle = 0;
12268 gl.deleteTextures(1, &m_to_invalid);
12274 m_pname_invalid = 0;
12276 while (GL_NO_ERROR != gl.getError())
12280 /******************************** Generate Mipmap Errors Test Implementation ********************************/
12282 /** @brief Generate Mipmap Errors Test constructor.
12284 * @param [in] context OpenGL context.
12286 GenerateMipmapErrorsTest::GenerateMipmapErrorsTest(deqp::Context& context)
12287 : deqp::TestCase(context, "textures_generate_mipmap_errors", "Texture Generate Mipmap Errors Test")
12289 /* Intentionally left blank. */
12292 /** @brief Iterate Generate Mipmap Errors Test cases.
12294 * @return Iteration result.
12296 tcu::TestNode::IterateResult GenerateMipmapErrorsTest::iterate()
12298 /* Shortcut for GL functionality. */
12299 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
12301 /* Get context setup. */
12302 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
12303 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
12305 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
12307 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
12312 /* Running tests. */
12314 bool is_error = false;
12317 glw::GLuint texture_invalid = 0;
12318 glw::GLuint texture_cube = 0;
12322 /* Preparations. */
12324 /* incomplete cube map */
12325 gl.genTextures(1, &texture_cube);
12326 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
12328 gl.bindTexture(GL_TEXTURE_CUBE_MAP, texture_cube);
12329 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
12331 gl.texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, s_reference_internalformat, s_reference_width,
12332 s_reference_height, 0, s_reference_format, s_reference_type, s_reference_data);
12333 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
12335 /* invalid texture */
12336 while (gl.isTexture(++texture_invalid))
12339 /* Check that INVALID_OPERATION is generated by GenerateTextureMipmap if
12340 texture is not the name of an existing texture object. */
12341 gl.generateTextureMipmap(texture_invalid);
12342 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGenerateTextureMipmap",
12343 "texture is not the name of an existing texture object.");
12345 /* Check that INVALID_OPERATION is generated by GenerateTextureMipmap if
12346 target is TEXTURE_CUBE_MAP or TEXTURE_CUBE_MAP_ARRAY, and the specified
12347 texture object is not cube complete or cube array complete,
12349 gl.generateTextureMipmap(texture_cube);
12350 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGenerateTextureMipmap",
12351 "target is TEXTURE_CUBE_MAP or TEXTURE_CUBE_MAP_ARRAY, and the specified texture "
12352 "object is not cube complete or cube array complete, respectively.");
12363 gl.deleteTextures(1, &texture_cube);
12366 while (GL_NO_ERROR != gl.getError())
12369 /* Result's setup. */
12372 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
12378 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
12382 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
12389 /** Reference data. */
12390 const glw::GLubyte GenerateMipmapErrorsTest::s_reference_data[] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
12391 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF };
12393 /** Reference data parameters. */
12394 const glw::GLuint GenerateMipmapErrorsTest::s_reference_width = 4;
12395 const glw::GLuint GenerateMipmapErrorsTest::s_reference_height = 4;
12396 const glw::GLenum GenerateMipmapErrorsTest::s_reference_internalformat = GL_R8;
12397 const glw::GLenum GenerateMipmapErrorsTest::s_reference_format = GL_RED;
12398 const glw::GLenum GenerateMipmapErrorsTest::s_reference_type = GL_UNSIGNED_BYTE;
12400 /******************************** Bind Unit Errors Test Implementation ********************************/
12402 /** @brief Bind Unit Errors Test constructor.
12404 * @param [in] context OpenGL context.
12406 BindUnitErrorsTest::BindUnitErrorsTest(deqp::Context& context)
12407 : deqp::TestCase(context, "textures_bind_unit_errors", "Texture Bind Unit Errors Test")
12409 /* Intentionally left blank. */
12412 /** @brief IterateBind Unit Errors Test cases.
12414 * @return Iteration result.
12416 tcu::TestNode::IterateResult BindUnitErrorsTest::iterate()
12418 /* Shortcut for GL functionality. */
12419 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
12421 /* Get context setup. */
12422 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
12423 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
12425 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
12427 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
12432 /* Running tests. */
12434 bool is_error = false;
12437 glw::GLuint texture_invalid = 0;
12441 /* Prepare invalid texture */
12442 while (gl.isTexture(++texture_invalid))
12445 /* incomplete cube map */
12447 /* Check that INVALID_OPERATION error is generated if texture is not zero
12448 or the name of an existing texture object. */
12449 gl.bindTextureUnit(0, texture_invalid);
12450 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glBindTextureUnit",
12451 "texture is not zero or the name of an existing texture object.");
12460 while (GL_NO_ERROR != gl.getError())
12463 /* Result's setup. */
12466 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
12472 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
12476 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
12483 /******************************** Image Query Errors Test Implementation ********************************/
12485 /** @brief Image Query Errors Test constructor.
12487 * @param [in] context OpenGL context.
12489 ImageQueryErrorsTest::ImageQueryErrorsTest(deqp::Context& context)
12490 : deqp::TestCase(context, "textures_image_query_errors", "Texture Image Query Errors Test")
12492 /* Intentionally left blank. */
12495 /** Reference data. */
12496 const glw::GLuint ImageQueryErrorsTest::s_reference_data[] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
12497 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF };
12499 /** Reference data parameters. */
12500 const glw::GLuint ImageQueryErrorsTest::s_reference_width = 4;
12501 const glw::GLuint ImageQueryErrorsTest::s_reference_height = 4;
12502 const glw::GLuint ImageQueryErrorsTest::s_reference_size = sizeof(s_reference_data);
12503 const glw::GLenum ImageQueryErrorsTest::s_reference_internalformat = GL_R8;
12504 const glw::GLenum ImageQueryErrorsTest::s_reference_internalformat_int = GL_R8I;
12505 const glw::GLenum ImageQueryErrorsTest::s_reference_internalformat_compressed = GL_COMPRESSED_RED_RGTC1;
12506 const glw::GLenum ImageQueryErrorsTest::s_reference_format = GL_RED;
12507 const glw::GLenum ImageQueryErrorsTest::s_reference_type = GL_UNSIGNED_INT;
12509 /** @brief Iterate Image Query Errors Test cases.
12511 * @return Iteration result.
12513 tcu::TestNode::IterateResult ImageQueryErrorsTest::iterate()
12515 /* Shortcut for GL functionality. */
12516 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
12518 /* Get context setup. */
12519 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
12520 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
12522 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
12524 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
12529 /* Running tests. */
12531 bool is_error = false;
12534 glw::GLuint buffer = 0;
12535 glw::GLuint texture_invalid = 0;
12536 glw::GLuint texture_2D = 0;
12537 glw::GLuint texture_2D_int = 0;
12538 glw::GLuint texture_2D_ms = 0;
12539 glw::GLuint texture_2D_stencil = 0;
12540 glw::GLuint texture_2D_compressed = 0;
12541 glw::GLuint texture_cube = 0;
12542 glw::GLuint texture_rectangle = 0;
12543 glw::GLint max_level = 0;
12544 char store[s_reference_size * 6 /* for cubemap */] = {};
12548 /* Preparations. */
12551 gl.createBuffers(1, &buffer);
12553 gl.namedBufferData(buffer, s_reference_size + 1, NULL, GL_STATIC_COPY);
12554 GLU_EXPECT_NO_ERROR(gl.getError(), "glNamedBufferData has failed");
12557 gl.genTextures(1, &texture_2D);
12558 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
12560 gl.bindTexture(GL_TEXTURE_2D, texture_2D);
12561 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
12563 gl.texImage2D(GL_TEXTURE_2D, 0, s_reference_internalformat, s_reference_width, s_reference_height, 0,
12564 s_reference_format, s_reference_type, s_reference_data);
12565 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
12568 gl.genTextures(1, &texture_2D);
12569 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
12571 gl.bindTexture(GL_TEXTURE_2D, texture_2D);
12572 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
12574 gl.texImage2D(GL_TEXTURE_2D, 0, s_reference_internalformat, s_reference_width, s_reference_height, 0,
12575 s_reference_format, s_reference_type, s_reference_data);
12576 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
12578 /* incomplete cube map */
12579 gl.genTextures(1, &texture_cube);
12580 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
12582 gl.bindTexture(GL_TEXTURE_CUBE_MAP, texture_cube);
12583 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
12585 gl.texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, s_reference_internalformat, s_reference_width,
12586 s_reference_height, 0, s_reference_format, s_reference_type, s_reference_data);
12587 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
12589 /* 2D multisample */
12590 gl.createTextures(GL_TEXTURE_2D_MULTISAMPLE, 1, &texture_2D_ms);
12591 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
12593 gl.textureStorage2DMultisample(texture_2D_ms, 1, s_reference_internalformat, s_reference_width,
12594 s_reference_height, false);
12595 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage2DMultisample has failed");
12598 gl.createTextures(GL_TEXTURE_2D, 1, &texture_2D_stencil);
12599 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
12601 gl.textureStorage2D(texture_2D_stencil, 1, GL_STENCIL_INDEX8, s_reference_width, s_reference_height);
12602 GLU_EXPECT_NO_ERROR(gl.getError(), "glTextureStorage2DMultisample has failed");
12604 /* 2D compressed texture */
12605 gl.genTextures(1, &texture_2D_compressed);
12606 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
12608 gl.bindTexture(GL_TEXTURE_2D, texture_2D_compressed);
12609 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
12611 gl.texImage2D(GL_TEXTURE_2D, 0, s_reference_internalformat_compressed, s_reference_width, s_reference_height, 0,
12612 s_reference_format, s_reference_type, s_reference_data);
12613 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
12615 gl.getIntegerv(GL_MAX_TEXTURE_SIZE, &max_level); /* assuming that x > log(x) */
12616 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
12618 /* Rectangle texture */
12619 gl.genTextures(1, &texture_rectangle);
12620 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
12622 gl.bindTexture(GL_TEXTURE_RECTANGLE, texture_rectangle);
12623 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
12625 gl.texImage2D(GL_TEXTURE_RECTANGLE, 0, s_reference_internalformat, s_reference_width, s_reference_height, 0,
12626 s_reference_format, s_reference_type, s_reference_data);
12627 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
12629 /* invalid texture */
12630 while (gl.isTexture(++texture_invalid))
12635 /* Check that INVALID_ENUM is generated by GetTextureImage functions if
12636 resulting texture target is not an accepted value TEXTURE_1D,
12637 TEXTURE_2D, TEXTURE_3D, TEXTURE_1D_ARRAY, TEXTURE_2D_ARRAY,
12638 TEXTURE_CUBE_MAP_ARRAY, TEXTURE_RECTANGLE, and TEXTURE_CUBE_MAP. */
12639 gl.getTextureImage(texture_2D_ms, 0, s_reference_format, s_reference_type, s_reference_size, store);
12640 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glGetTextureImage",
12641 "resulting texture target is not an accepted value TEXTURE_1D, TEXTURE_2D, "
12642 "TEXTURE_3D, TEXTURE_1D_ARRAY, TEXTURE_2D_ARRAY, TEXTURE_CUBE_MAP_ARRAY, "
12643 "TEXTURE_RECTANGLE, and TEXTURE_CUBE_MAP.");
12645 /* Check that INVALID_OPERATION is generated by GetTextureImage
12646 if texture is not the name of an existing texture object. */
12647 gl.getTextureImage(texture_invalid, 0, s_reference_format, s_reference_type, s_reference_size, store);
12648 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12649 "texture is not the name of an existing texture object.");
12651 /* Check that INVALID_OPERATION error is generated by GetTextureImage if
12652 the effective target is TEXTURE_CUBE_MAP or TEXTURE_CUBE_MAP_ARRAY, and
12653 the texture object is not cube complete or cube array complete,
12655 gl.getTextureImage(texture_cube, 0, s_reference_format, s_reference_type, s_reference_size * 6, store);
12656 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12657 "the effective target is TEXTURE_CUBE_MAP and the texture object is not cube "
12658 "complete or cube array complete, respectively.");
12660 /* Check that GL_INVALID_VALUE is generated if level is less than 0 or
12661 larger than the maximum allowable level. */
12662 gl.getTextureImage(texture_2D, -1, s_reference_format, s_reference_type, s_reference_size, store);
12663 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glGetTextureImage", "level is less than 0.");
12665 gl.getTextureImage(texture_2D, max_level, s_reference_format, s_reference_type, s_reference_size, store);
12666 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glGetTextureImage",
12667 "level is larger than the maximum allowable level.");
12669 /* Check that INVALID_VALUE error is generated if level is non-zero and the
12670 effective target is TEXTURE_RECTANGLE. */
12671 gl.getTextureImage(texture_rectangle, 1, s_reference_format, s_reference_type, s_reference_size, store);
12672 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glGetTextureImage",
12673 "level is non-zero and the effective target is TEXTURE_RECTANGLE.");
12675 /* Check that INVALID_OPERATION error is generated if any of the following
12676 mismatches between format and the internal format of the texture image
12678 - format is a color format (one of the formats in table 8.3 whose
12679 target is the color buffer) and the base internal format of the
12680 texture image is not a color format.
12681 - format is DEPTH_COMPONENT and the base internal format is not
12682 DEPTH_COMPONENT or DEPTH_STENCIL
12683 - format is DEPTH_STENCIL and the base internal format is not
12685 - format is STENCIL_INDEX and the base internal format is not
12686 STENCIL_INDEX or DEPTH_STENCIL
12687 - format is one of the integer formats in table 8.3 and the internal
12688 format of the texture image is not integer, or format is not one of
12689 the integer formats in table 8.3 and the internal format is integer. */
12690 gl.getTextureImage(texture_2D_stencil, 0, s_reference_format /* red */, s_reference_type, s_reference_size,
12692 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12693 "format is a color format (one of the formats in table 8.3 whose target is the color "
12694 "buffer) and the base internal format of the texture image is not a color format.");
12696 gl.getTextureImage(texture_2D, 0, GL_DEPTH_COMPONENT, s_reference_type, s_reference_size, store);
12697 is_ok &= CheckErrorAndLog(
12698 m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12699 "format is DEPTH_COMPONENT and the base internal format is not DEPTH_COMPONENT or DEPTH_STENCIL.");
12701 gl.getTextureImage(texture_2D, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, s_reference_size, store);
12702 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12703 "format is DEPTH_STENCIL and the base internal format is not DEPTH_STENCIL.");
12705 gl.getTextureImage(texture_2D, 0, GL_STENCIL_INDEX, s_reference_type, s_reference_size, store);
12706 is_ok &= CheckErrorAndLog(
12707 m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12708 "format is STENCIL_INDEX and the base internal format is not STENCIL_INDEX or DEPTH_STENCIL.");
12710 gl.getTextureImage(texture_2D, 0, GL_RED_INTEGER, s_reference_type, s_reference_size, store);
12711 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12712 "format is one of the integer formats in table 8.3 and the internal format of the "
12713 "texture image is not integer.");
12715 gl.getTextureImage(texture_2D_int, 0, GL_RED, s_reference_type, s_reference_size, store);
12716 is_ok &= CheckErrorAndLog(
12717 m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12718 "format is not one of the integer formats in table 8.3 and the internal format is integer.");
12720 /* Check that INVALID_OPERATION error is generated if a pixel pack buffer
12721 object is bound and packing the texture image into the buffer’s memory
12722 would exceed the size of the buffer. */
12723 gl.bindBuffer(GL_PIXEL_PACK_BUFFER, buffer);
12724 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
12726 gl.getTextureImage(texture_2D, 0, s_reference_format, s_reference_type, s_reference_size,
12727 (glw::GLuint*)NULL + 1);
12728 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12729 "a pixel pack buffer object is bound and packing the texture image into the buffer’s "
12730 "memory would exceed the size of the buffer.");
12732 gl.bindBuffer(GL_PIXEL_PACK_BUFFER, 0);
12733 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
12735 /* Check that INVALID_OPERATION error is generated if a pixel pack buffer
12736 object is bound and pixels is not evenly divisible by the number of
12737 basic machine units needed to store in memory the GL data type
12738 corresponding to type (see table 8.2). */
12739 gl.bindBuffer(GL_PIXEL_PACK_BUFFER, buffer);
12740 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
12742 gl.getTextureImage(texture_2D, 0, s_reference_format, s_reference_type, s_reference_size,
12743 (glw::GLubyte*)NULL + 1);
12744 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12745 "a pixel pack buffer object is bound and pixels is not evenly divisible by the "
12746 "number of basic machine units needed to store in memory the GL data type "
12747 "corresponding to type (see table 8.2).");
12749 gl.bindBuffer(GL_PIXEL_PACK_BUFFER, 0);
12750 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
12752 /* Check that INVALID_OPERATION error is generated by GetTextureImage if
12753 the buffer size required to store the requested data is greater than
12755 gl.getTextureImage(texture_2D, 0, s_reference_format, s_reference_type,
12756 s_reference_size - sizeof(s_reference_data[0]), store);
12757 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureImage",
12758 "the buffer size required to store the requested data is greater than bufSize.");
12760 /* Check that INVALID_OPERATION is generated by GetCompressedTextureImage
12761 if texture is not the name of an existing texture object. */
12762 gl.getCompressedTextureImage(texture_invalid, 0, s_reference_size, store);
12763 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetCompressedTextureImage",
12764 "texture is not the name of an existing texture object.");
12766 /* Check that INVALID_VALUE is generated by GetCompressedTextureImage if
12767 level is less than zero or greater than the maximum number of LODs
12768 permitted by the implementation. */
12769 gl.getCompressedTextureImage(texture_2D_compressed, -1, s_reference_size, store);
12771 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glGetCompressedTextureImage", "level is less than zero.");
12773 gl.getCompressedTextureImage(texture_2D_compressed, max_level, s_reference_size, store);
12774 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glGetCompressedTextureImage",
12775 "level is greater than the maximum number of LODs permitted by the implementation.");
12777 /* Check that INVALID_OPERATION is generated if GetCompressedTextureImage
12778 is used to retrieve a texture that is in an uncompressed internal
12780 gl.getCompressedTextureImage(texture_2D, 0, s_reference_size, store);
12782 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetCompressedTextureImage",
12783 "the function is used to retrieve a texture that is in an uncompressed internal format.");
12785 /* Check that INVALID_OPERATION is generated by GetCompressedTextureImage
12786 if a non-zero buffer object name is bound to the PIXEL_PACK_BUFFER
12787 target, the buffer storage was not initialized with BufferStorage using
12788 MAP_PERSISTENT_BIT flag, and the buffer object's data store is currently
12790 gl.bindBuffer(GL_PIXEL_PACK_BUFFER, buffer);
12791 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
12793 gl.mapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_WRITE);
12795 if (GL_NO_ERROR == gl.getError())
12797 gl.getCompressedTextureImage(texture_2D_compressed, 0, s_reference_size, NULL);
12798 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetCompressedTextureImage",
12799 "a non-zero buffer object name is bound to the PIXEL_PACK_BUFFER target, the "
12800 "buffer storage was not initialized with BufferStorage using MAP_PERSISTENT_BIT "
12801 "flag, and the buffer object's data store is currently mapped.");
12803 gl.unmapBuffer(GL_PIXEL_PACK_BUFFER);
12804 GLU_EXPECT_NO_ERROR(gl.getError(), "glUnmapBuffer has failed");
12811 gl.bindBuffer(GL_PIXEL_PACK_BUFFER, 0);
12812 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
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 and the data would be packed to the buffer object such that the
12817 memory writes required would exceed the data store size. */
12818 gl.bindBuffer(GL_PIXEL_PACK_BUFFER, buffer);
12819 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
12821 gl.getCompressedTextureImage(texture_2D_compressed, 0, s_reference_size, (char*)NULL + s_reference_size - 1);
12822 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetCompressedTextureImage",
12823 "a non-zero buffer object name is bound to the PIXEL_PACK_BUFFER target and the data "
12824 "would be packed to the buffer object such that the memory writes required would "
12825 "exceed the data store size.");
12827 gl.bindBuffer(GL_PIXEL_PACK_BUFFER, 0);
12828 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
12839 gl.deleteBuffers(1, &buffer);
12844 gl.deleteTextures(1, &texture_2D);
12847 if (texture_2D_int)
12849 gl.deleteTextures(1, &texture_2D_int);
12852 if (texture_2D_stencil)
12854 gl.deleteTextures(1, &texture_2D_stencil);
12859 gl.deleteTextures(1, &texture_2D_ms);
12862 if (texture_2D_compressed)
12864 gl.deleteTextures(1, &texture_2D_compressed);
12869 gl.deleteTextures(1, &texture_cube);
12872 if (texture_rectangle)
12874 gl.deleteTextures(1, &texture_rectangle);
12877 while (GL_NO_ERROR != gl.getError())
12880 /* Result's setup. */
12883 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
12889 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
12893 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
12900 /******************************** Level Parameter Query Errors Test Implementation ********************************/
12902 /** @brief Image Query Errors Test constructor.
12904 * @param [in] context OpenGL context.
12906 LevelParameterErrorsTest::LevelParameterErrorsTest(deqp::Context& context)
12907 : deqp::TestCase(context, "textures_level_parameter_errors", "Texture Level Parameter Query Errors Test")
12909 /* Intentionally left blank. */
12912 /** @brief Iterate Level Parameter Query Errors Test cases.
12914 * @return Iteration result.
12916 tcu::TestNode::IterateResult LevelParameterErrorsTest::iterate()
12918 /* Shortcut for GL functionality. */
12919 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
12921 /* Get context setup. */
12922 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
12923 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
12925 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
12927 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
12932 /* Running tests. */
12934 bool is_error = false;
12937 glw::GLuint texture_2D = 0;
12938 glw::GLuint texture_invalid = 0;
12939 glw::GLint max_level = 0;
12940 glw::GLenum pname_invalid = 0;
12942 glw::GLfloat storef[4] = {};
12943 glw::GLint storei[4] = {};
12947 /* Preparations. */
12950 gl.genTextures(1, &texture_2D);
12951 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
12953 gl.bindTexture(GL_TEXTURE_2D, texture_2D);
12954 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
12956 gl.texStorage2D(GL_TEXTURE_2D, 1, GL_R8, 1, 1);
12957 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D has failed");
12960 gl.getIntegerv(GL_MAX_TEXTURE_SIZE, &max_level); /* assuming that x > log(x) */
12961 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
12963 /* invalid texture */
12964 while (gl.isTexture(++texture_invalid))
12967 /* invalid pname */
12968 glw::GLenum all_pnames[] = { GL_TEXTURE_WIDTH,
12971 GL_TEXTURE_SAMPLES,
12972 GL_TEXTURE_FIXED_SAMPLE_LOCATIONS,
12973 GL_TEXTURE_INTERNAL_FORMAT,
12974 GL_TEXTURE_RED_SIZE,
12975 GL_TEXTURE_GREEN_SIZE,
12976 GL_TEXTURE_BLUE_SIZE,
12977 GL_TEXTURE_ALPHA_SIZE,
12978 GL_TEXTURE_DEPTH_SIZE,
12979 GL_TEXTURE_STENCIL_SIZE,
12980 GL_TEXTURE_SHARED_SIZE,
12981 GL_TEXTURE_RED_TYPE,
12982 GL_TEXTURE_GREEN_TYPE,
12983 GL_TEXTURE_BLUE_TYPE,
12984 GL_TEXTURE_ALPHA_TYPE,
12985 GL_TEXTURE_DEPTH_TYPE,
12986 GL_TEXTURE_COMPRESSED,
12987 GL_TEXTURE_COMPRESSED_IMAGE_SIZE,
12988 GL_TEXTURE_BUFFER_DATA_STORE_BINDING,
12989 GL_TEXTURE_BUFFER_OFFSET,
12990 GL_TEXTURE_BUFFER_SIZE };
12992 glw::GLuint all_pnames_count = sizeof(all_pnames) / sizeof(all_pnames[0]);
12994 bool is_valid = true;
13002 for (glw::GLuint i = 0; i < all_pnames_count; ++i)
13004 if (all_pnames[i] == pname_invalid)
13015 /* Check that INVALID_OPERATION is generated by GetTextureLevelParameterfv
13016 and GetTextureLevelParameteriv functions if texture is not the name of
13017 an existing texture object. */
13018 gl.getTextureLevelParameterfv(texture_invalid, 0, GL_TEXTURE_WIDTH, storef);
13019 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureLevelParameterfv",
13020 "texture is not the name of an existing texture object.");
13022 gl.getTextureLevelParameteriv(texture_invalid, 0, GL_TEXTURE_WIDTH, storei);
13023 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureLevelParameteriv",
13024 "texture is not the name of an existing texture object.");
13026 /* Check that INVALID_VALUE is generated by GetTextureLevelParameter* if
13027 level is less than 0. */
13028 gl.getTextureLevelParameterfv(texture_2D, -1, GL_TEXTURE_WIDTH, storef);
13029 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glGetTextureLevelParameterfv", "level is less than 0.");
13031 gl.getTextureLevelParameteriv(texture_2D, -1, GL_TEXTURE_WIDTH, storei);
13032 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glGetTextureLevelParameteriv", "level is less than 0.");
13034 /* Check that INVALID_ENUM error is generated by GetTextureLevelParameter*
13035 if pname is not one of supported constants. */
13036 gl.getTextureLevelParameterfv(texture_2D, 0, pname_invalid, storef);
13037 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glGetTextureLevelParameterfv",
13038 "pname is not one of supported constants.");
13040 gl.getTextureLevelParameteriv(texture_2D, 0, pname_invalid, storei);
13041 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glGetTextureLevelParameteriv",
13042 "pname is not one of supported constants.");
13044 /* Check that INVALID_VALUE may be generated if level is greater than
13045 log2 max, where max is the returned value of MAX_TEXTURE_SIZE. */
13046 gl.getTextureLevelParameterfv(texture_2D, max_level, GL_TEXTURE_WIDTH, storef);
13048 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glGetTextureLevelParameterfv",
13049 "level is greater than log2 max, where max is the returned value of MAX_TEXTURE_SIZE.");
13051 gl.getTextureLevelParameteriv(texture_2D, max_level, GL_TEXTURE_WIDTH, storei);
13053 CheckErrorAndLog(m_context, GL_INVALID_VALUE, "glGetTextureLevelParameteriv",
13054 "level is greater than log2 max, where max is the returned value of MAX_TEXTURE_SIZE.");
13056 /* Check that INVALID_OPERATION is generated by GetTextureLevelParameter*
13057 if TEXTURE_COMPRESSED_IMAGE_SIZE is queried on texture images with an
13058 uncompressed internal format or on proxy targets. */
13059 gl.getTextureLevelParameterfv(texture_2D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, storef);
13060 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureLevelParameterfv",
13061 "TEXTURE_COMPRESSED_IMAGE_SIZE is queried on texture images with an uncompressed "
13062 "internal format or on proxy targets.");
13064 gl.getTextureLevelParameteriv(texture_2D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, storei);
13065 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureLevelParameteriv",
13066 "TEXTURE_COMPRESSED_IMAGE_SIZE is queried on texture images with an uncompressed "
13067 "internal format or on proxy targets.");
13078 gl.deleteTextures(1, &texture_2D);
13081 while (GL_NO_ERROR != gl.getError())
13084 /* Result's setup. */
13087 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
13093 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
13097 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
13104 /******************************** Parameter Query Errors Test Implementation ********************************/
13106 /** @brief Parameter Query Errors Test constructor.
13108 * @param [in] context OpenGL context.
13110 ParameterErrorsTest::ParameterErrorsTest(deqp::Context& context)
13111 : deqp::TestCase(context, "textures_parameter_errors", "Texture Parameter Query Errors Test")
13113 /* Intentionally left blank. */
13116 /** @brief Iterate Parameter Query Errors Test cases.
13118 * @return Iteration result.
13120 tcu::TestNode::IterateResult ParameterErrorsTest::iterate()
13122 /* Shortcut for GL functionality. */
13123 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
13125 /* Get context setup. */
13126 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
13127 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
13129 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
13131 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
13136 /* Running tests. */
13138 bool is_error = false;
13141 glw::GLuint texture_2D = 0;
13142 glw::GLuint texture_buffer = 0;
13143 glw::GLuint texture_invalid = 0;
13144 glw::GLenum pname_invalid = 0;
13146 glw::GLfloat storef[4] = {};
13147 glw::GLint storei[4] = {};
13148 glw::GLuint storeu[4] = {};
13152 /* Preparations. */
13155 gl.createTextures(GL_TEXTURE_2D, 1, &texture_2D);
13156 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
13158 /* Buffer texture */
13159 gl.createTextures(GL_TEXTURE_BUFFER, 1, &texture_buffer);
13160 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
13162 /* invalid texture */
13163 while (gl.isTexture(++texture_invalid))
13166 /* invalid pname */
13167 glw::GLenum all_pnames[] = { GL_IMAGE_FORMAT_COMPATIBILITY_TYPE,
13168 GL_TEXTURE_IMMUTABLE_FORMAT,
13169 GL_TEXTURE_IMMUTABLE_LEVELS,
13171 GL_TEXTURE_VIEW_MIN_LEVEL,
13172 GL_TEXTURE_VIEW_NUM_LEVELS,
13173 GL_TEXTURE_VIEW_MIN_LAYER,
13174 GL_TEXTURE_VIEW_NUM_LAYERS,
13175 GL_DEPTH_STENCIL_TEXTURE_MODE,
13176 GL_DEPTH_COMPONENT,
13178 GL_TEXTURE_BASE_LEVEL,
13179 GL_TEXTURE_BORDER_COLOR,
13180 GL_TEXTURE_COMPARE_MODE,
13181 GL_TEXTURE_COMPARE_FUNC,
13182 GL_TEXTURE_LOD_BIAS,
13183 GL_TEXTURE_MAG_FILTER,
13184 GL_TEXTURE_MAX_LEVEL,
13185 GL_TEXTURE_MAX_LOD,
13186 GL_TEXTURE_MIN_FILTER,
13187 GL_TEXTURE_MIN_LOD,
13188 GL_TEXTURE_SWIZZLE_R,
13189 GL_TEXTURE_SWIZZLE_G,
13190 GL_TEXTURE_SWIZZLE_B,
13191 GL_TEXTURE_SWIZZLE_A,
13192 GL_TEXTURE_SWIZZLE_RGBA,
13195 GL_TEXTURE_WRAP_R };
13197 glw::GLuint all_pnames_count = sizeof(all_pnames) / sizeof(all_pnames[0]);
13199 bool is_valid = true;
13207 for (glw::GLuint i = 0; i < all_pnames_count; ++i)
13209 if (all_pnames[i] == pname_invalid)
13220 /* Check that INVALID_ENUM is generated by glGetTextureParameter* if pname
13221 is not an accepted value. */
13222 gl.getTextureParameterfv(texture_2D, pname_invalid, storef);
13224 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glGetTextureParameterfv", "pname is not an accepted value.");
13226 gl.getTextureParameterIiv(texture_2D, pname_invalid, storei);
13228 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glGetTextureParameterIiv", "pname is not an accepted value.");
13230 gl.getTextureParameterIuiv(texture_2D, pname_invalid, storeu);
13231 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glGetTextureParameterIuiv",
13232 "pname is not an accepted value.");
13234 gl.getTextureParameteriv(texture_2D, pname_invalid, storei);
13236 CheckErrorAndLog(m_context, GL_INVALID_ENUM, "glGetTextureParameteriv", "pname is not an accepted value.");
13238 /* Check that INVALID_OPERATION is generated by glGetTextureParameter* if
13239 texture is not the name of an existing texture object. */
13240 gl.getTextureParameterfv(texture_invalid, GL_TEXTURE_TARGET, storef);
13241 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureParameterfv",
13242 "texture is not the name of an existing texture object.");
13244 gl.getTextureParameterIiv(texture_invalid, GL_TEXTURE_TARGET, storei);
13245 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureParameterIiv",
13246 "texture is not the name of an existing texture object.");
13248 gl.getTextureParameterIuiv(texture_invalid, GL_TEXTURE_TARGET, storeu);
13249 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureParameterIuiv",
13250 "texture is not the name of an existing texture object.");
13252 gl.getTextureParameteriv(texture_invalid, GL_TEXTURE_TARGET, storei);
13253 is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureParameteriv",
13254 "texture is not the name of an existing texture object.");
13256 /* Check that INVALID_OPERATION error is generated if the effective target is
13257 not one of the supported texture targets (eg. TEXTURE_BUFFER). */
13258 gl.getTextureParameterfv(texture_buffer, GL_TEXTURE_TARGET, storef);
13260 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureParameterfv",
13261 "the effective target is not one of the supported texture targets (eg. TEXTURE_BUFFER).");
13263 gl.getTextureParameterIiv(texture_buffer, GL_TEXTURE_TARGET, storei);
13265 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureParameterIiv",
13266 "the effective target is not one of the supported texture targets (eg. TEXTURE_BUFFER).");
13268 gl.getTextureParameterIuiv(texture_buffer, GL_TEXTURE_TARGET, storeu);
13270 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureParameterIuiv",
13271 "the effective target is not one of the supported texture targets (eg. TEXTURE_BUFFER).");
13273 gl.getTextureParameteriv(texture_buffer, GL_TEXTURE_TARGET, storei);
13275 CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureParameteriv",
13276 "the effective target is not one of the supported texture targets (eg. TEXTURE_BUFFER).");
13287 gl.deleteTextures(1, &texture_2D);
13290 if (texture_buffer)
13292 gl.deleteTextures(1, &texture_buffer);
13295 while (GL_NO_ERROR != gl.getError())
13298 /* Result's setup. */
13301 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
13307 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
13311 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
13318 } /* Textures namespace. */
13319 } /* DirectStateAccess namespace. */
13320 } /* gl4cts namespace. */