From: Cheryl Wei Date: Mon, 4 Jan 2021 07:23:46 +0000 (+0800) Subject: Fix ReadPixels format X-Git-Tag: upstream/1.3.5~436^2~9^2~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a815d38d34cd67dbb894ea85756a9fc96676a94f;p=platform%2Fupstream%2FVK-GL-CTS.git Fix ReadPixels format Pass implementation format to ReadPixels when pixel format is 8,8,8,0 because some implementations treat RGB8 as RGBA8888 which causes these tests to fail. Affected tests: KHR-GLES3.core.nearest_edge.offset_* KHR-GLES31.core.nearest_edge.offset_* Components: OpenGL ES VK-GL-CTS issue: 2712 Change-Id: I6ce92f19d2e329c75ca5fc6800092af623e25829 (cherry picked from commit 780408248fd9e84162f7f6ccf94677952ab0d0da) --- diff --git a/external/openglcts/modules/common/glcNearestEdgeTests.cpp b/external/openglcts/modules/common/glcNearestEdgeTests.cpp index f9c754a..f4d3710 100644 --- a/external/openglcts/modules/common/glcNearestEdgeTests.cpp +++ b/external/openglcts/modules/common/glcNearestEdgeTests.cpp @@ -73,7 +73,7 @@ public: static std::string getName (OffsetDirection direction); static std::string getDesc (OffsetDirection direction); - static tcu::TextureFormat toTextureFormat (const tcu::PixelFormat& pixelFmt); + static tcu::TextureFormat toTextureFormat (deqp::Context& context, const tcu::PixelFormat& pixelFmt); private: static const glw::GLenum kTextureType = GL_TEXTURE_2D; @@ -123,7 +123,7 @@ std::string NearestEdgeTestCase::getDesc (OffsetDirection direction) // Translate pixel format in the frame buffer to texture format. // Copied from sglrReferenceContext.cpp. -tcu::TextureFormat NearestEdgeTestCase::toTextureFormat (const tcu::PixelFormat& pixelFmt) +tcu::TextureFormat NearestEdgeTestCase::toTextureFormat (deqp::Context& context, const tcu::PixelFormat& pixelFmt) { static const struct { @@ -143,7 +143,24 @@ tcu::TextureFormat NearestEdgeTestCase::toTextureFormat (const tcu::PixelFormat& for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pixelFormatMap); ndx++) { if (pixelFormatMap[ndx].pixelFmt == pixelFmt) - return pixelFormatMap[ndx].texFmt; + { + // 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)) + { + 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; + } + } } TCU_FAIL("Unable to map pixel format to texture format"); @@ -155,7 +172,7 @@ NearestEdgeTestCase::NearestEdgeTestCase (deqp::Context& context, OffsetDirectio , m_width {context.getRenderTarget().getWidth()} , m_height {context.getRenderTarget().getHeight()} , m_format {context.getRenderTarget().getPixelFormat()} - , m_texFormat {toTextureFormat(m_format)} + , m_texFormat {toTextureFormat(context, m_format)} , m_texFormatInfo {tcu::getTextureFormatInfo(m_texFormat)} , m_transFormat {glu::getTransferFormat(m_texFormat)} {