Commit d33a806f by Geoff Lang Committed by Commit Bot

Fix Image11::copyFromFramebuffer for emulated texture formats.

Simply using the ReadPixels code paths to unpack the framebuffer into a texture was insufficient for handling cases like LUMA or RGB textures that are emulated with RGBA textures in D3D11. Instead, read the framebuffer's data into a buffer and then use the loading functions which are aware of the emulated formats to write the data to the destionation. Fix LUMA format structure's logic for reading colors. They aren't supposed to do any averaging logic. BUG=angleproject:1095 BUG=483282 Change-Id: Iad91d193d4c824573d9e9cafd28cf456d2de8be5 Reviewed-on: https://chromium-review.googlesource.com/354482Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 9e55a966
......@@ -356,10 +356,11 @@ gl::Error Image11::copyFromFramebuffer(const gl::Offset &destOffset,
const gl::FramebufferAttachment *srcAttachment = sourceFBO->getReadColorbuffer();
ASSERT(srcAttachment);
const auto &d3d11Format = d3d11::GetTextureFormatInfo(srcAttachment->getInternalFormat(),
mRenderer->getRenderer11DeviceCaps());
GLenum sourceInternalFormat = srcAttachment->getInternalFormat();
const auto &d3d11Format =
d3d11::GetTextureFormatInfo(sourceInternalFormat, mRenderer->getRenderer11DeviceCaps());
if (d3d11Format.formatSet->texFormat == mDXGIFormat)
if (d3d11Format.formatSet->texFormat == mDXGIFormat && sourceInternalFormat == mInternalFormat)
{
RenderTargetD3D *renderTarget = nullptr;
gl::Error error = srcAttachment->getRenderTarget(&renderTarget);
......@@ -396,11 +397,32 @@ gl::Error Image11::copyFromFramebuffer(const gl::Offset &destOffset,
mappedImage.RowPitch * destOffset.y + rowOffset +
destOffset.z * mappedImage.DepthPitch;
const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(mInternalFormat);
const gl::InternalFormat &destFormatInfo = gl::GetInternalFormatInfo(mInternalFormat);
const auto &destD3D11Format =
d3d11::GetTextureFormatInfo(mInternalFormat, mRenderer->getRenderer11DeviceCaps());
error = mRenderer->readFromAttachment(*srcAttachment, sourceArea, formatInfo.format,
formatInfo.type, mappedImage.RowPitch,
gl::PixelPackState(), dataOffset);
auto loadFunction = destD3D11Format.loadFunctions.at(destFormatInfo.type);
if (loadFunction.requiresConversion)
{
size_t bufferSize = destFormatInfo.pixelBytes * sourceArea.width * sourceArea.height;
MemoryBuffer *memoryBuffer = nullptr;
mRenderer->getScratchMemoryBuffer(bufferSize, &memoryBuffer);
GLuint memoryBufferRowPitch = destFormatInfo.pixelBytes * sourceArea.width;
error = mRenderer->readFromAttachment(*srcAttachment, sourceArea, destFormatInfo.format,
destFormatInfo.type, memoryBufferRowPitch,
gl::PixelPackState(), memoryBuffer->data());
loadFunction.loadFunction(sourceArea.width, sourceArea.height, 1, memoryBuffer->data(),
memoryBufferRowPitch, 0, dataOffset, mappedImage.RowPitch,
mappedImage.DepthPitch);
}
else
{
error = mRenderer->readFromAttachment(*srcAttachment, sourceArea, destFormatInfo.format,
destFormatInfo.type, mappedImage.RowPitch,
gl::PixelPackState(), dataOffset);
}
unmap();
mDirty = true;
......
......@@ -36,7 +36,7 @@ struct L8
static void writeColor(L8 *dst, const gl::ColorF *src)
{
dst->L = gl::floatToNormalized<unsigned char>((src->red + src->green + src->blue) / 3.0f);
dst->L = gl::floatToNormalized<unsigned char>(src->red);
}
static void average(L8 *dst, const L8 *src1, const L8 *src2)
......@@ -120,7 +120,7 @@ struct L8A8
static void writeColor(L8A8 *dst, const gl::ColorF *src)
{
dst->L = gl::floatToNormalized<unsigned char>((src->red + src->green + src->blue) / 3.0f);
dst->L = gl::floatToNormalized<unsigned char>(src->red);
dst->A = gl::floatToNormalized<unsigned char>(src->alpha);
}
......@@ -148,7 +148,7 @@ struct A8L8
static void writeColor(A8L8 *dst, const gl::ColorF *src)
{
dst->L = gl::floatToNormalized<unsigned char>((src->red + src->green + src->blue) / 3.0f);
dst->L = gl::floatToNormalized<unsigned char>(src->red);
dst->A = gl::floatToNormalized<unsigned char>(src->alpha);
}
......@@ -1617,7 +1617,7 @@ struct L16F
static void writeColor(L16F *dst, const gl::ColorF *src)
{
dst->L = gl::float32ToFloat16((src->red + src->green + src->blue) / 3.0f);
dst->L = gl::float32ToFloat16(src->red);
}
static void average(L16F *dst, const L16F *src1, const L16F *src2)
......@@ -1642,7 +1642,7 @@ struct L16A16F
static void writeColor(L16A16F *dst, const gl::ColorF *src)
{
dst->L = gl::float32ToFloat16((src->red + src->green + src->blue) / 3.0f);
dst->L = gl::float32ToFloat16(src->red);
dst->A = gl::float32ToFloat16(src->alpha);
}
......@@ -1826,7 +1826,7 @@ struct L32F
static void writeColor(L32F *dst, const gl::ColorF *src)
{
dst->L = (src->red + src->green + src->blue) / 3.0f;
dst->L = src->red;
}
static void average(L32F *dst, const L32F *src1, const L32F *src2)
......@@ -1850,7 +1850,7 @@ struct L32A32F
static void writeColor(L32A32F *dst, const gl::ColorF *src)
{
dst->L = (src->red + src->green + src->blue) / 3.0f;
dst->L = src->red;
dst->A = src->alpha;
}
......
......@@ -118,9 +118,6 @@
1095 WIN : dEQP-GLES3.functional.texture.specification.teximage2d_depth_pbo.depth32f_stencil8 = FAIL
1095 WIN : dEQP-GLES3.functional.texture.specification.texsubimage2d_depth.depth_component32f = FAIL
1095 WIN : dEQP-GLES3.functional.texture.specification.texsubimage2d_depth.depth32f_stencil8 = FAIL
1095 WIN : dEQP-GLES3.functional.texture.specification.basic_copyteximage2d.cube_luminance = FAIL
1095 WIN : dEQP-GLES3.functional.texture.specification.basic_copyteximage2d.cube_luminance_alpha = FAIL
1095 WIN : dEQP-GLES3.functional.texture.specification.basic_copyteximage2d.cube_rgb = FAIL
1095 WIN : dEQP-GLES3.functional.texture.specification.basic_copytexsubimage2d.2d_rgba = FAIL
1095 WIN : dEQP-GLES3.functional.texture.specification.basic_copytexsubimage2d.2d_alpha = FAIL
1095 WIN : dEQP-GLES3.functional.texture.specification.basic_copytexsubimage2d.2d_luminance_alpha = FAIL
......
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