Commit 1ffad843 by Frank Henigman Committed by Commit Bot

Remove PixelPackState from PackPixelsParams.

Only one flag ("reverseRowOrder") from PixelPackState was being used, so instead of including the entire struct in PackPixelsParams, just include the one flag. BUG=angleproject:2718 Change-Id: I32e8b30383d198ecba9bf1719c32dda0938fc969 Reviewed-on: https://chromium-review.googlesource.com/1242210 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@google.com>
parent 1dfd8ae2
......@@ -263,8 +263,9 @@ angle::Result Framebuffer11::readPixelsImpl(const gl::Context *context,
{
Buffer11 *packBufferStorage = GetImplAs<Buffer11>(packBuffer);
const angle::Format &angleFormat = GetFormatFromFormatType(format, type);
PackPixelsParams packParams(area, angleFormat, static_cast<GLuint>(outputPitch), pack,
packBuffer, reinterpret_cast<ptrdiff_t>(pixels));
PackPixelsParams packParams(area, angleFormat, static_cast<GLuint>(outputPitch),
pack.reverseRowOrder, packBuffer,
reinterpret_cast<ptrdiff_t>(pixels));
return packBufferStorage->packPixels(context, *readAttachment, packParams);
}
......
......@@ -3039,9 +3039,11 @@ angle::Result Renderer11::readFromAttachment(const gl::Context *context,
const gl::Extents &texSize = textureHelper.getExtents();
gl::Rectangle actualArea = sourceArea;
bool reverseRowOrder = pack.reverseRowOrder;
if (invertTexture)
{
actualArea.y = texSize.height - actualArea.y - actualArea.height;
reverseRowOrder = !reverseRowOrder;
}
// Clamp read region to the defined texture boundaries, preventing out of bounds reads
......@@ -3122,22 +3124,8 @@ angle::Result Renderer11::readFromAttachment(const gl::Context *context,
const angle::Format &angleFormat = GetFormatFromFormatType(format, type);
gl::Buffer *packBuffer = context->getGLState().getTargetBuffer(gl::BufferBinding::PixelPack);
if (!invertTexture)
{
PackPixelsParams packParams(safeArea, angleFormat, outputPitch, pack, packBuffer, 0);
return packPixels(context, stagingHelper, packParams, pixelsOut);
}
// Create a new PixelPackState with reversed row order. Note that we can't just assign
// 'invertTexturePack' to be 'pack' (or memcpy) since that breaks the ref counting/object
// tracking in the 'pixelBuffer' members, causing leaks. Instead we must use
// pixelBuffer.set() twice, which performs the addRef/release correctly
gl::PixelPackState invertTexturePack;
invertTexturePack.alignment = pack.alignment;
invertTexturePack.reverseRowOrder = !pack.reverseRowOrder;
PackPixelsParams packParams(safeArea, angleFormat, outputPitch, invertTexturePack, packBuffer,
0);
PackPixelsParams packParams(safeArea, angleFormat, outputPitch, reverseRowOrder, packBuffer, 0);
return packPixels(context, stagingHelper, packParams, pixelsOut);
}
......
......@@ -203,7 +203,7 @@ angle::Result Framebuffer9::readPixelsImpl(const gl::Context *context,
packParams.area.height = rect.bottom - rect.top;
packParams.destFormat = &GetFormatFromFormatType(format, type);
packParams.outputPitch = static_cast<GLuint>(outputPitch);
packParams.pack = pack;
packParams.reverseRowOrder = pack.reverseRowOrder;
PackPixels(packParams, d3dFormatInfo.info(), inputPitch, source, pixels);
......
......@@ -169,18 +169,16 @@ PackPixelsParams::PackPixelsParams()
PackPixelsParams::PackPixelsParams(const gl::Rectangle &areaIn,
const angle::Format &destFormat,
GLuint outputPitchIn,
const gl::PixelPackState &packIn,
bool reverseRowOrderIn,
gl::Buffer *packBufferIn,
ptrdiff_t offsetIn)
: area(areaIn),
destFormat(&destFormat),
outputPitch(outputPitchIn),
packBuffer(packBufferIn),
pack(),
reverseRowOrder(reverseRowOrderIn),
offset(offsetIn)
{
pack.alignment = packIn.alignment;
pack.reverseRowOrder = packIn.reverseRowOrder;
}
void PackPixels(const PackPixelsParams &params,
......@@ -194,7 +192,7 @@ void PackPixels(const PackPixelsParams &params,
const uint8_t *source = sourceIn;
int inputPitch = inputPitchIn;
if (params.pack.reverseRowOrder)
if (params.reverseRowOrder)
{
source += inputPitch * (params.area.height - 1);
inputPitch = -inputPitch;
......
......@@ -153,7 +153,7 @@ struct PackPixelsParams
PackPixelsParams(const gl::Rectangle &area,
const angle::Format &destFormat,
GLuint outputPitch,
const gl::PixelPackState &pack,
bool reverseRowOrderIn,
gl::Buffer *packBufferIn,
ptrdiff_t offset);
......@@ -161,7 +161,7 @@ struct PackPixelsParams
const angle::Format *destFormat;
GLuint outputPitch;
gl::Buffer *packBuffer;
gl::PixelPackState pack;
bool reverseRowOrder;
ptrdiff_t offset;
};
......
......@@ -358,12 +358,7 @@ gl::Error FramebufferVk::readPixels(const gl::Context *context,
}
const gl::State &glState = context->getGLState();
gl::PixelPackState packState(glState.getPackState());
if (contextVk->isViewportFlipEnabledForReadFBO())
{
packState.reverseRowOrder = !packState.reverseRowOrder;
}
const gl::PixelPackState &packState = glState.getPackState();
const gl::InternalFormat &sizedFormatInfo = gl::GetInternalFormatInfo(format, type);
......@@ -379,8 +374,12 @@ gl::Error FramebufferVk::readPixels(const gl::Context *context,
const angle::Format &angleFormat = GetFormatFromFormatType(format, type);
PackPixelsParams params(flippedArea, angleFormat, outputPitch, packState,
PackPixelsParams params(flippedArea, angleFormat, outputPitch, packState.reverseRowOrder,
glState.getTargetBuffer(gl::BufferBinding::PixelPack), 0);
if (contextVk->isViewportFlipEnabledForReadFBO())
{
params.reverseRowOrder = !params.reverseRowOrder;
}
ANGLE_TRY(readPixelsImpl(contextVk, flippedArea, params, VK_IMAGE_ASPECT_COLOR_BIT,
getColorReadRenderTarget(),
......@@ -437,8 +436,7 @@ angle::Result FramebufferVk::blitWithReadback(ContextVk *contextVk,
// This path is only currently used for y-flipping depth/stencil blits.
PackPixelsParams packPixelsParams;
packPixelsParams.pack.alignment = 1;
packPixelsParams.pack.reverseRowOrder = true;
packPixelsParams.reverseRowOrder = true;
packPixelsParams.area.width = copyArea.width;
packPixelsParams.area.height = copyArea.height;
packPixelsParams.area.x = copyArea.x;
......
......@@ -206,19 +206,10 @@ angle::Result PixelBuffer::stageSubresourceUpdateFromFramebuffer(
ANGLE_TRY(mStagingBuffer.allocate(contextVk, allocationSize, &stagingPointer, &bufferHandle,
&stagingOffset, &newBufferAllocated));
gl::PixelPackState pixelPackState = gl::PixelPackState();
// TODO(lucferron): The pixel pack state alignment should probably be 1 instead of 4.
// http://anglebug.com/2718
if (isViewportFlipEnabled)
{
pixelPackState.reverseRowOrder = !pixelPackState.reverseRowOrder;
}
const angle::Format &copyFormat =
GetFormatFromFormatType(formatInfo.internalFormat, formatInfo.type);
PackPixelsParams params(clippedRectangle, copyFormat, static_cast<GLuint>(outputRowPitch),
pixelPackState, nullptr, 0);
isViewportFlipEnabled, nullptr, 0);
// 2- copy the source image region to the pixel buffer using a cpu readback
if (loadFunction.requiresConversion)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment