Skip to content

Commit

Permalink
Fix pixel pack/unpack in nearest edge tests
Browse files Browse the repository at this point in the history
With certain fbconfigs and width/height combos, this would
corrupt memory due to overwriting too many bytes by 1.

Components: OpenGL

VK-GL-CTS Issue: 2496

Affects: KHR-GL46.nearest_edge.offset_*
         KHR-GLES32.core.nearest_edge.offset*

Change-Id: I2b31c8791337555b0bb154cea1f676f0daf43c7e
(cherry picked from commit 9486b75)
  • Loading branch information
airlied authored and sunsun02 committed Aug 17, 2020
1 parent d4d482a commit e77699a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions external/openglcts/modules/common/glcNearestEdgeTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ void NearestEdgeTestCase::fillTexture ()
}

const auto internalFormat = glu::getInternalFormat(m_texFormat);
if (tcu::getPixelSize(m_texFormat) < 4)
gl.pixelStorei(GL_UNPACK_ALIGNMENT, 1);
gl.texImage2D(kTextureType, 0, internalFormat, m_width, m_height, 0 /* border */, m_transFormat.format, m_transFormat.dataType, m_texData.data());
GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D");
}
Expand Down Expand Up @@ -323,6 +325,8 @@ bool NearestEdgeTestCase::verifyResults ()
const auto& gl = m_context.getRenderContext().getFunctions();

std::vector<deUint8> fbData(m_width * m_height * tcu::getPixelSize(m_texFormat));
if (tcu::getPixelSize(m_texFormat) < 4)
gl.pixelStorei(GL_PACK_ALIGNMENT, 1);
gl.readPixels(0, 0, m_width, m_height, m_transFormat.format, m_transFormat.dataType, fbData.data());
GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels");

Expand Down

0 comments on commit e77699a

Please sign in to comment.