Render to FBO in etc2_texture test
authorPiotr Byszewski <piotr.byszewski@mobica.com>
Thu, 31 Aug 2017 11:21:48 +0000 (13:21 +0200)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Thu, 31 Aug 2017 14:18:11 +0000 (10:18 -0400)
etc2_texture renders to a new frame buffer to prevent
GL_INVALID_OPERATION from being generated by glReadPixels.
This could happen when etc2_texture was executed after
max_texture_units.

Components: OpenGL

VK-GL-CTS issue: 654

Affects:
KHR-GLES32.core.texture_cube_map_array.etc2_texture
KHR-GL44.texture_cube_map_array.etc2_texture
KHR-GL45.texture_cube_map_array.etc2_texture

Change-Id: Ia9f358dbed1d583aab813e97bc29f5ae02304d7d

external/openglcts/modules/glesext/texture_cube_map_array/esextcTextureCubeMapArrayETC2Support.cpp
external/openglcts/modules/glesext/texture_cube_map_array/esextcTextureCubeMapArrayETC2Support.hpp

index d1200ff..8ebf7d3 100644 (file)
@@ -67,6 +67,7 @@ void TextureCubeMapArrayETC2Support::deinit(void)
  */
 tcu::TestCase::IterateResult TextureCubeMapArrayETC2Support::iterate(void)
 {
+       prepareFramebuffer();
        prepareProgram();
        prepareVertexArrayObject();
        prepareTexture();
@@ -81,6 +82,34 @@ tcu::TestCase::IterateResult TextureCubeMapArrayETC2Support::iterate(void)
        return STOP;
 }
 
+/** @brief Bind default framebuffer object.
+ *
+ *  @note The function may throw if unexpected error has occured.
+ */
+void TextureCubeMapArrayETC2Support::prepareFramebuffer()
+{
+       /* Shortcut for GL functionality */
+       const glw::Functions& gl = m_context.getRenderContext().getFunctions();
+
+       gl.genRenderbuffers(1, &m_rbo);
+       GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
+
+       gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo);
+       GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
+
+       gl.renderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, RENDER_WIDTH, RENDER_HEIGHT);
+       GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage call failed.");
+
+       gl.genFramebuffers(1, &m_fbo);
+       GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
+
+       gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
+       GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
+
+       gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo);
+       GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer call failed.");
+}
+
 /** @brief Function generate and bind empty vertex array object.
  *
  *  @note The function may throw if unexpected error has occured.
index a1a899a..f0529d0 100644 (file)
@@ -42,6 +42,7 @@ public:
        virtual IterateResult iterate(void);
 
 protected:
+       void prepareFramebuffer();
        void prepareVertexArrayObject();
        void prepareProgram();
        void prepareTexture();