From 2fce7996f200ccd59b3e915b049dd4c6019ee87d Mon Sep 17 00:00:00 2001 From: Piers Daniell Date: Tue, 26 Jan 2021 10:19:30 -0700 Subject: [PATCH] Return a valid format when GL_RGB8 is not treated as GL_RGBA8 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 --- .../openglcts/modules/common/glcNearestEdgeTests.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/external/openglcts/modules/common/glcNearestEdgeTests.cpp b/external/openglcts/modules/common/glcNearestEdgeTests.cpp index f4d3710..688e4bb 100644 --- a/external/openglcts/modules/common/glcNearestEdgeTests.cpp +++ b/external/openglcts/modules/common/glcNearestEdgeTests.cpp @@ -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; } } -- 2.7.4