Commit 976f356d authored by bsalomon@google.com's avatar bsalomon@google.com

Fix for GL_CHROMIUM_flipy in TexSubImage2D and unit test

TEST=none
BUG=none
Review URL: http://codereview.chromium.org/8587040

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110923 0039d316-1c4b-4281-b951-d872f2087c98
parent 96fa62bf
......@@ -1569,7 +1569,7 @@ void GLES2Implementation::TexSubImage2DImpl(
return;
}
GLsizei original_height = height;
GLint original_yoffset = yoffset;
if (padded_row_size <= max_size) {
// Transfer by rows.
GLint max_rows = max_size / std::max(padded_row_size,
......@@ -1584,7 +1584,7 @@ void GLES2Implementation::TexSubImage2DImpl(
CopyRectToBufferFlipped(
source, width, num_rows, format, type, buffer);
// GPU_DCHECK(copy_success); // can't check this because bot fails!
y = original_height - yoffset - num_rows;
y = original_yoffset + height - num_rows;
} else {
memcpy(buffer, source, part_size);
y = yoffset;
......@@ -1614,7 +1614,7 @@ void GLES2Implementation::TexSubImage2DImpl(
GLsizeiptr part_size = num_pixels * element_size;
void* buffer = transfer_buffer_.Alloc(part_size);
memcpy(buffer, row_source, part_size);
GLint y = unpack_flip_y_ ? (original_height - yoffset - 1) : yoffset;
GLint y = unpack_flip_y_ ? (original_yoffset + height - 1) : yoffset;
helper_->TexSubImage2D(
target, level, temp_xoffset, y, num_pixels, 1, format, type,
transfer_buffer_id_, transfer_buffer_.GetOffset(buffer), internal);
......
......@@ -1755,6 +1755,74 @@ TEST_F(GLES2ImplementationTest, TexImage2DSubRows) {
GetTransferAddressFromOffsetAs<uint8>(offset4, part_size)));
}
// Test TexSubImage2D with GL_PACK_FLIP_Y set and partial multirow transfers
TEST_F(GLES2ImplementationTest, TexSubImage2DFlipY) {
const GLsizei kTextureWidth = MaxTransferBufferSize() / 4;
const GLsizei kTextureHeight = 7;
const GLsizei kSubImageWidth = MaxTransferBufferSize() / 8;
const GLsizei kSubImageHeight = 4;
const GLint kSubImageXOffset = 1;
const GLint kSubImageYOffset = 2;
const GLenum kFormat = GL_RGBA;
const GLenum kType = GL_UNSIGNED_BYTE;
const GLenum kTarget = GL_TEXTURE_2D;
const GLint kLevel = 0;
const GLint kBorder = 0;
const GLint kPixelStoreUnpackAlignment = 4;
struct Cmds {
PixelStorei pixel_store_i1;
TexImage2D tex_image_2d;
TexSubImage2D tex_sub_image_2d1;
cmd::SetToken set_token1;
TexSubImage2D tex_sub_image_2d2;
cmd::SetToken set_token2;
};
uint32 sub_2_high_size = 0;
ASSERT_TRUE(GLES2Util::ComputeImageDataSize(
kSubImageWidth, 2, kFormat, kType, kPixelStoreUnpackAlignment,
&sub_2_high_size));
uint32 offset1 = AllocateTransferBuffer(sub_2_high_size);
uint32 offset2 = AllocateTransferBuffer(sub_2_high_size);
Cmds expected;
expected.pixel_store_i1.Init(GL_UNPACK_ALIGNMENT, kPixelStoreUnpackAlignment);
expected.tex_image_2d.Init(
kTarget, kLevel, kFormat, kTextureWidth, kTextureHeight, kBorder, kFormat,
kType, 0, NULL);
expected.tex_sub_image_2d1.Init(kTarget, kLevel, kSubImageXOffset,
kSubImageYOffset + 2, kSubImageWidth, 2, kFormat, kType,
kTransferBufferId, offset1, false);
expected.set_token1.Init(GetNextToken());
expected.tex_sub_image_2d2.Init(kTarget, kLevel, kSubImageXOffset,
kSubImageYOffset, kSubImageWidth , 2, kFormat, kType, kTransferBufferId,
offset2, false);
expected.set_token2.Init(GetNextToken());
gl_->PixelStorei(GL_UNPACK_ALIGNMENT, kPixelStoreUnpackAlignment);
gl_->TexImage2D(
kTarget, kLevel, kFormat, kTextureWidth, kTextureHeight, kBorder, kFormat,
kType, NULL);
// this call should not emit commands (handled client-side)
gl_->PixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE);
scoped_array<uint32> pixels(new uint32[kSubImageWidth * kSubImageHeight]);
for (int y = 0; y < kSubImageHeight; ++y) {
for (int x = 0; x < kSubImageWidth; ++x) {
pixels.get()[kSubImageWidth * y + x] = x | (y << 16);
}
}
gl_->TexSubImage2D(
GL_TEXTURE_2D, 0, kSubImageXOffset, kSubImageYOffset, kSubImageWidth,
kSubImageHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixels.get());
EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
EXPECT_TRUE(CheckRect(
kSubImageWidth, 2, kFormat, kType, kPixelStoreUnpackAlignment, true,
reinterpret_cast<uint8*>(pixels.get() + 2 * kSubImageWidth),
GetTransferAddressFromOffsetAs<uint8>(offset2, sub_2_high_size)));
}
// Test that GenBuffer does not call GenSharedIds.
// This is because with client side arrays on we know the StrictSharedIdHandler
// for buffers has already gotten a set of ids
......
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