Skip to content

Commit

Permalink
Fix read size validation for RGBX formats.
Browse files Browse the repository at this point in the history
GL_RGBX8_ANGLE is the only format where the upload format is 3-channel
RGB, whilethe download format is 4-channel RGBX.  As such, the internal
format corresponding to format+type expects 3-byte input/output.  The
format is fixed here for readPixels to output 4 bytes per pixel.

Bug: chromium:1458046
Change-Id: Iec737ed64bade003cfab50dc5f595eb4875e81e4
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4706957
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
  • Loading branch information
vonture authored and Angle LUCI CQ committed Jul 23, 2023
1 parent 938ee1e commit 430a4f5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
10 changes: 9 additions & 1 deletion src/libANGLE/formatutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1702,7 +1702,15 @@ const InternalFormat &GetInternalFormatInfo(GLenum internalFormat, GLenum type)
GLuint InternalFormat::computePixelBytes(GLenum formatType) const
{
const auto &typeInfo = GetTypeInfo(formatType);
GLuint components = typeInfo.specialInterpretation ? 1u : componentCount;
GLuint components = componentCount;
if (sizedInternalFormat == GL_RGBX8_ANGLE)
{
components = 4;
}
else if (typeInfo.specialInterpretation)
{
components = 1;
}
return components * typeInfo.bytes;
}

Expand Down
9 changes: 0 additions & 9 deletions src/libANGLE/renderer/vulkan/FramebufferVk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -813,15 +813,6 @@ angle::Result FramebufferVk::readPixels(const gl::Context *context,
gl::Buffer *packBuffer,
void *pixels)
{
// Note that GL_RGBX8_ANGLE is the only format where the upload format is 3-channel RGB, while
// the download format is 4-channel RGBX. As such, the internal format corresponding to
// format+type expects 3-byte input/output. The format is fixed here for readPixels to output
// 4 bytes per pixel.
if (format == GL_RGBX8_ANGLE)
{
format = GL_RGBA8;
}

// Clip read area to framebuffer.
const gl::Extents &fbSize = getState().getReadPixelsAttachment(format)->getSize();
const gl::Rectangle fbRect(0, 0, fbSize.width, fbSize.height);
Expand Down

0 comments on commit 430a4f5

Please sign in to comment.