Some glCopyTexSubImage3D related tests conflict with GLES3.2 spec
authorYabin Zheng <yabin.zheng@arm.com>
Fri, 22 Jun 2018 01:50:06 +0000 (09:50 +0800)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Mon, 16 Jul 2018 10:49:27 +0000 (06:49 -0400)
According to the GLES3.2 spec,  An INVALID_OPERATION error is generated if the
component sizes of internalformat do not exactly match the corresponding
component sizes of the source buffer's effective internal format when call the
glCopyTExSubImage3D function.

The test format is GL_RGBA8, while different config ID will result in different
format in the render buffer. The number of channel bits of some format are not
equal to GL_RGBA8. So we should add a new FBO to restrict the test behavior.

Components: OpenGL

Affects: KHR-GLES2.texture_3d.copy_sub_image.*

VK-GL-CTS issue: 1240

Change-Id: I35c066fce990038e95da1e04197d659929fd8e86

external/openglcts/modules/gles2/es2cTexture3DTests.cpp

index 6424f1b..32a0851 100644 (file)
@@ -817,6 +817,25 @@ CopyTexSubImage3DCase::IterateResult CopyTexSubImage3DCase::iterate(void)
        const tcu::TextureFormat         textureFormat = texture.getRefTexture().getFormat();
        const tcu::TextureFormatInfo formatInfo = tcu::getTextureFormatInfo(textureFormat);
 
+       /* According to the spec, the component sizes of internalformat should exactly match the corresponding component sizes
+          of the source buffer's effective internal format when call the glCopyTexSubImage3D function. Because the test format
+          is GL_RGBA8, so we should create a new texture with the same format and attach it to a new fbo. */
+       glw::GLuint fbo = 0;
+       gl.genFramebuffers(1, &fbo);
+       gl.bindFramebuffer(GL_FRAMEBUFFER, fbo);
+       glw::GLuint new_dst_to = 0;
+       gl.genTextures(1, &new_dst_to);
+       gl.bindTexture(GL_TEXTURE_2D, new_dst_to);
+
+       /* The longest edge of texture(32*64*8) is 64, so we create a texture with 64*64 dimension. */
+       gl.texImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+       GLU_EXPECT_NO_ERROR(gl.getError(),
+                                               "Could not setup texture object for draw framebuffer color attachment.");
+
+       gl.framebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, new_dst_to, 0);
+
+       GLU_EXPECT_NO_ERROR(gl.getError(),
+                                               "Could not attach texture object to draw framebuffer color attachment.");
        // Fill texture.
        for (int levelNdx = 0; levelNdx < m_numLevels; levelNdx++)
        {
@@ -877,6 +896,9 @@ CopyTexSubImage3DCase::IterateResult CopyTexSubImage3DCase::iterate(void)
 
        // Compare rendered image to reference.
        verifyTestResult(texCoord[0].getPtr(), rendered, texture.getRefTexture(), refParams, false);
+       gl.deleteTextures(1, &new_dst_to);
+       gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
+       gl.deleteFramebuffers(1, &fbo);
        return STOP;
 }