Return a valid format when GL_RGB8 is not treated as GL_RGBA8
authorPiers Daniell <pdaniell@nvidia.com>
Tue, 26 Jan 2021 17:19:30 +0000 (10:19 -0700)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Thu, 28 Jan 2021 16:28:46 +0000 (16:28 +0000)
There was a special case added to NearestEdgeTestCase::toTextureFormat()
in https://gerrit.khronos.org/c/vk-gl-cts/+/6634 to support implementations
that treat GLRGB8 internally as GL_RGBA8888. This code change had a coding
error is that for implementations that don't support GLRGB8 in this way
ended up aborting with a fatal error:
    "Unable to map pixel format to texture format"

This trivial fix corrects the coding bug to simply return the
unadjusted format.

Affects:

KHR-GLES3.core.nearest_edge.offset_*
KHR-GLES31.core.nearest_edge.offset_*

Components: OpenGL

VK-GL-CTS issue: 2758

Change-Id: I639aed8bfed70941688d30edb02a770be4b05b08

external/openglcts/modules/common/glcNearestEdgeTests.cpp

index f4d3710..688e4bb 100644 (file)
@@ -145,21 +145,19 @@ tcu::TextureFormat NearestEdgeTestCase::toTextureFormat (deqp::Context& context,
                if (pixelFormatMap[ndx].pixelFmt == pixelFmt)
                {
                        // Some implementations treat GL_RGB8 as GL_RGBA8888,so the test should pass implementation format to ReadPixels.
-                       if (pixelFmt == tcu::PixelFormat(8,8,8,0))
+                       if (pixelFmt == tcu::PixelFormat(8, 8, 8, 0))
                        {
                                const auto& gl = context.getRenderContext().getFunctions();
 
                                glw::GLint implFormat = GL_NONE;
-                               glw::GLint implType   = GL_NONE;
-                               gl.getIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT,&implFormat);
-                               gl.getIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE,&implType);
-                               if(implFormat == GL_RGBA && implType == GL_UNSIGNED_BYTE)
-                                       return tcu::TextureFormat(tcu::TextureFormat::RGBA,     tcu::TextureFormat::UNORM_INT8);
-                       }
-                       else
-                       {
-                               return pixelFormatMap[ndx].texFmt;
+                               glw::GLint implType       = GL_NONE;
+                               gl.getIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &implFormat);
+                               gl.getIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &implType);
+                               if (implFormat == GL_RGBA && implType == GL_UNSIGNED_BYTE)
+                                       return tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8);
                        }
+
+                       return pixelFormatMap[ndx].texFmt;
                }
        }