Re-land "D3D11: Fix readback of BGRA-backed formats."
For some BGRA-backed formats (RGBA4, R5G6B5, RGB5A1), our ReadPixels
implementation wasn't aware the BGRA format didn't exactly match the
RGBA format. For these it would do the 'fast path' memcpy method, when
it should stop and do the slow pixel-by-pixel packing method.
Fixes conformance2/reading/read-pixels-from-fbo-test.html.
Reland: fix empty format info that was causing us to only see the
first pixel in the FBO in a ReadPixels call. Also fix bugs in the
unorm 16-bit format readback code, and add ASSERTs to catch bugs in
subsequent new formats.
BUG=angleproject:1407
BUG=chromium:616176
Change-Id: I9fd55b9e1dd6a306eb4db195d775c02a1eb1f93f
Reviewed-on: https://chromium-review.googlesource.com/357132
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/formatutils.cpp b/src/libANGLE/formatutils.cpp
index c9533aa..3fd42d3 100644
--- a/src/libANGLE/formatutils.cpp
+++ b/src/libANGLE/formatutils.cpp
@@ -462,6 +462,9 @@
map.insert(InternalFormatInfoPair(GL_BGRA4_ANGLEX, RGBAFormat( 4, 4, 4, 4, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888>, RequireExt<&Extensions::textureFormatBGRA8888>, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_BGR5_A1_ANGLEX, RGBAFormat( 5, 5, 5, 1, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888>, RequireExt<&Extensions::textureFormatBGRA8888>, AlwaysSupported)));
+ // Special format which is not really supported, so always false for all supports.
+ map.insert(InternalFormatInfoPair(GL_BGR565_ANGLEX, RGBAFormat( 5, 6, 5, 1, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported)));
+
// Floating point renderability and filtering is provided by OES_texture_float and OES_texture_half_float
// | Internal format | | D |S | Format | Type | Comp | SRGB | Texture supported | Renderable | Filterable |
// | | | | | | | type | | | | |
@@ -610,12 +613,15 @@
{
FormatSet result;
- const InternalFormatInfoMap &formats = GetInternalFormatMap();
- for (InternalFormatInfoMap::const_iterator i = formats.begin(); i != formats.end(); i++)
+ for (auto iter : GetInternalFormatMap())
{
- if (i->second.pixelBytes > 0)
+ if (iter.second.pixelBytes > 0)
{
- result.insert(i->first);
+ // TODO(jmadill): Fix this hack.
+ if (iter.first == GL_BGR565_ANGLEX)
+ continue;
+
+ result.insert(iter.first);
}
}
@@ -681,7 +687,7 @@
const InternalFormat &GetInternalFormatInfo(GLenum internalFormat)
{
const InternalFormatInfoMap &formatMap = GetInternalFormatMap();
- InternalFormatInfoMap::const_iterator iter = formatMap.find(internalFormat);
+ auto iter = formatMap.find(internalFormat);
if (iter != formatMap.end())
{
return iter->second;
@@ -689,6 +695,7 @@
else
{
static const InternalFormat defaultInternalFormat;
+ UNREACHABLE();
return defaultInternalFormat;
}
}