Skip to content

Commit fc33f0a

Browse files
Shufen MaAngle LUCI CQ
authored andcommitted
Add a ReadPixels test for offset alignment check
An INVALID_OPERATION error is generated if a pixel pack buffer object is bound and data is not evenly divisible by the number of basic machine units needed to store in memory the corresponding GL data type from table 8.4 for the type parameter. Add a test for this. Bug: angleproject:352963094 Change-Id: I81eda446df5ff29da1326a1f75f5d5aa0825aafd Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6170763 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com>
1 parent ab7457d commit fc33f0a

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

src/tests/gl_tests/ReadPixelsTest.cpp

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,6 +1552,68 @@ TEST_P(ReadPixelsErrorTest, ColorBufferSnorm16)
15521552
{GL_BYTE, GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT});
15531553
}
15541554

1555+
// texture internal format is GL_RGBA32F
1556+
class ReadPixelsFloat32TypePBOTest : public ReadPixelsPBOTest
1557+
{
1558+
protected:
1559+
ReadPixelsFloat32TypePBOTest() : ReadPixelsPBOTest() {}
1560+
1561+
void testSetUp() override
1562+
{
1563+
glGenBuffers(1, &mPBO);
1564+
glGenFramebuffers(1, &mFBO);
1565+
1566+
// buffer size sufficient enough for glReadPixels when data != 0
1567+
reset(4 * 4 * 1 * 4 + 16, 4, 1);
1568+
}
1569+
1570+
void reset(GLuint bufferSize, GLuint fboWidth, GLuint fboHeight) override
1571+
{
1572+
glBindBuffer(GL_PIXEL_PACK_BUFFER, mPBO);
1573+
glBufferData(GL_PIXEL_PACK_BUFFER, bufferSize, nullptr, GL_STATIC_DRAW);
1574+
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
1575+
1576+
glDeleteTextures(1, &mTexture);
1577+
glGenTextures(1, &mTexture);
1578+
glBindTexture(GL_TEXTURE_2D, mTexture);
1579+
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA32F, fboWidth, fboHeight);
1580+
1581+
glBindFramebuffer(GL_FRAMEBUFFER, mFBO);
1582+
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTexture, 0);
1583+
1584+
mFBOWidth = fboWidth;
1585+
mFBOHeight = fboHeight;
1586+
1587+
mPBOBufferSize = bufferSize;
1588+
1589+
ASSERT_GL_NO_ERROR();
1590+
}
1591+
};
1592+
1593+
// Test basic usage of PBOs.
1594+
TEST_P(ReadPixelsFloat32TypePBOTest, Basic)
1595+
{
1596+
glClearColor(0.5f, 0.2f, 0.3f, 0.4f);
1597+
glClear(GL_COLOR_BUFFER_BIT);
1598+
EXPECT_GL_NO_ERROR();
1599+
1600+
glBindBuffer(GL_PIXEL_PACK_BUFFER, mPBO);
1601+
glReadPixels(0, 0, mFBOWidth, mFBOHeight, GL_RGBA, GL_FLOAT, reinterpret_cast<void *>(2));
1602+
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
1603+
1604+
glReadPixels(0, 0, mFBOWidth, mFBOHeight, GL_RGBA, GL_FLOAT, 0);
1605+
EXPECT_GL_NO_ERROR();
1606+
1607+
void *mappedPtr = glMapBufferRange(GL_PIXEL_PACK_BUFFER, 0, mPBOBufferSize, GL_MAP_READ_BIT);
1608+
GLColor32F *dataColor = static_cast<GLColor32F *>(mappedPtr);
1609+
EXPECT_GL_NO_ERROR();
1610+
1611+
EXPECT_EQ(GLColor32F(0.5f, 0.2f, 0.3f, 0.4f), dataColor[0]);
1612+
1613+
glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
1614+
EXPECT_GL_NO_ERROR();
1615+
}
1616+
15551617
// a test class to be used for error checking of glReadPixels with WebGLCompatibility
15561618
class ReadPixelsWebGLErrorTest : public ReadPixelsTest
15571619
{
@@ -1616,6 +1678,9 @@ ANGLE_INSTANTIATE_TEST_ES2(ReadPixelsPBONVTest);
16161678
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(ReadPixelsPBOTest);
16171679
ANGLE_INSTANTIATE_TEST_ES3(ReadPixelsPBOTest);
16181680

1681+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(ReadPixelsFloat32TypePBOTest);
1682+
ANGLE_INSTANTIATE_TEST_ES3(ReadPixelsFloat32TypePBOTest);
1683+
16191684
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(ReadPixelsPBODrawTest);
16201685
ANGLE_INSTANTIATE_TEST_ES3_AND(ReadPixelsPBODrawTest,
16211686
ES3_VULKAN().enable(Feature::ForceFallbackFormat));

0 commit comments

Comments
 (0)