pjs/gfx/angle/angle-impl-read-bgra.patch

72 строки
3.1 KiB
Diff

From: Jeff Gilbert <jgilbert@mozilla.com>
Bug 724476 - ANGLE Bug 294 - Use BGRA/UBYTE as exposed fast format/type for readPixels
diff --git a/gfx/angle/src/libGLESv2/Context.cpp b/gfx/angle/src/libGLESv2/Context.cpp
--- a/gfx/angle/src/libGLESv2/Context.cpp
+++ b/gfx/angle/src/libGLESv2/Context.cpp
@@ -2520,16 +2520,17 @@ void Context::readPixels(GLint x, GLint
{
if (desc.Format == D3DFMT_A8R8G8B8 &&
format == GL_BGRA_EXT &&
type == GL_UNSIGNED_BYTE)
{
// Fast path for EXT_read_format_bgra, given
// an RGBA source buffer. Note that buffers with no
// alpha go through the slow path below.
+ // Note that this is also the combo exposed by IMPLEMENTATION_COLOR_READ_TYPE/FORMAT
memcpy(dest + j * outputPitch,
source + j * inputPitch,
(rect.right - rect.left) * 4);
continue;
}
for (int i = 0; i < rect.right - rect.left; i++)
{
@@ -2666,20 +2667,20 @@ void Context::readPixels(GLint x, GLint
((unsigned short)( a + 0.5f) << 15) |
((unsigned short)(31 * r + 0.5f) << 10) |
((unsigned short)(31 * g + 0.5f) << 5) |
((unsigned short)(31 * b + 0.5f) << 0);
break;
default: UNREACHABLE();
}
break;
- case GL_RGB: // IMPLEMENTATION_COLOR_READ_FORMAT
+ case GL_RGB:
switch (type)
{
- case GL_UNSIGNED_SHORT_5_6_5: // IMPLEMENTATION_COLOR_READ_TYPE
+ case GL_UNSIGNED_SHORT_5_6_5:
dest16[i + j * outputPitch / sizeof(unsigned short)] =
((unsigned short)(31 * b + 0.5f) << 0) |
((unsigned short)(63 * g + 0.5f) << 5) |
((unsigned short)(31 * r + 0.5f) << 11);
break;
default: UNREACHABLE();
}
break;
diff --git a/gfx/angle/src/libGLESv2/Context.h b/gfx/angle/src/libGLESv2/Context.h
--- a/gfx/angle/src/libGLESv2/Context.h
+++ b/gfx/angle/src/libGLESv2/Context.h
@@ -69,18 +69,18 @@ enum
MAX_VARYING_VECTORS_SM3 = 10,
MAX_TEXTURE_IMAGE_UNITS = 16,
MAX_VERTEX_TEXTURE_IMAGE_UNITS_VTF = 4, // For devices supporting vertex texture fetch
MAX_COMBINED_TEXTURE_IMAGE_UNITS_VTF = MAX_TEXTURE_IMAGE_UNITS + MAX_VERTEX_TEXTURE_IMAGE_UNITS_VTF,
MAX_FRAGMENT_UNIFORM_VECTORS_SM2 = 32 - 3, // Reserve space for dx_Coord, dx_Depth, and dx_DepthRange. dx_PointOrLines and dx_FrontCCW use separate bool registers.
MAX_FRAGMENT_UNIFORM_VECTORS_SM3 = 224 - 3,
MAX_DRAW_BUFFERS = 1,
- IMPLEMENTATION_COLOR_READ_FORMAT = GL_RGB,
- IMPLEMENTATION_COLOR_READ_TYPE = GL_UNSIGNED_SHORT_5_6_5
+ IMPLEMENTATION_COLOR_READ_FORMAT = GL_BGRA_EXT,
+ IMPLEMENTATION_COLOR_READ_TYPE = GL_UNSIGNED_BYTE
};
enum QueryType
{
QUERY_ANY_SAMPLES_PASSED,
QUERY_ANY_SAMPLES_PASSED_CONSERVATIVE,
QUERY_TYPE_COUNT