Commit f7d4f25e by Geoff Lang

D3D: Use an alignment of 1 when uploading zero data to initialize textures.

BUG=836131 Change-Id: I1206c8eda465da563e15cf43f2e5c9320bb65eae Reviewed-on: https://chromium-review.googlesource.com/1026460Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org> (cherry picked from commit f2807385) Reviewed-on: https://chromium-review.googlesource.com/1030890Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 5fd17eb7
......@@ -713,19 +713,20 @@ gl::Error TextureD3D::initializeContents(const gl::Context *context,
imageBytes);
imageBytes *= image->getHeight() * image->getDepth();
gl::PixelUnpackState defaultUnpackState;
gl::PixelUnpackState zeroDataUnpackState;
zeroDataUnpackState.alignment = 1;
angle::MemoryBuffer *zeroBuffer = nullptr;
ANGLE_TRY(context->getZeroFilledBuffer(imageBytes, &zeroBuffer));
if (shouldUseSetData(image))
{
ANGLE_TRY(mTexStorage->setData(context, imageIndex, image, nullptr, formatInfo.type,
defaultUnpackState, zeroBuffer->data()));
zeroDataUnpackState, zeroBuffer->data()));
}
else
{
gl::Box fullImageArea(0, 0, 0, image->getWidth(), image->getHeight(), image->getDepth());
ANGLE_TRY(image->loadData(context, fullImageArea, defaultUnpackState, formatInfo.type,
ANGLE_TRY(image->loadData(context, fullImageArea, zeroDataUnpackState, formatInfo.type,
zeroBuffer->data(), false));
// Force an update to the tex storage so we avoid problems with subImage and dirty regions.
......
......@@ -803,10 +803,15 @@ TEST_P(RobustResourceInitTestES3, ReadingOutOfboundsCopiedTextureWithUnpackBuffe
glBufferData(GL_PIXEL_UNPACK_BUFFER, sizeof(bunchOfGreen), bunchOfGreen.data(), GL_STATIC_DRAW);
EXPECT_GL_NO_ERROR();
// Use non-multiple-of-4 dimensions to make sure unpack alignment is set in the backends
// (http://crbug.com/836131)
constexpr int kTextureWidth = 127;
constexpr int kTextureHeight = 127;
// Use GL_ALPHA to force a CPU readback in the D3D11 backend
GLTexture texAlpha;
glBindTexture(GL_TEXTURE_2D, texAlpha);
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, x, y, kWidth, kHeight, 0);
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, x, y, kTextureWidth, kTextureHeight, 0);
EXPECT_GL_NO_ERROR();
// GL_ALPHA cannot be glReadPixels, so copy into a GL_RGBA texture
......
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