diff options
author | marha <marha@users.sourceforge.net> | 2012-01-28 13:55:41 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-01-28 13:55:41 +0100 |
commit | 1aee8dafb5391e093f3a111f906ab0d8b6775510 (patch) | |
tree | 3fd4cc1783510fb6ce17c4c42b4d012014008e5b /mesalib/src/mesa/main/formats.c | |
parent | c6a1477b0092762299491d79b3a8cb094c6456da (diff) | |
download | vcxsrv-1aee8dafb5391e093f3a111f906ab0d8b6775510.tar.gz vcxsrv-1aee8dafb5391e093f3a111f906ab0d8b6775510.tar.bz2 vcxsrv-1aee8dafb5391e093f3a111f906ab0d8b6775510.zip |
mesa xserver git update 28 jan 2012
Diffstat (limited to 'mesalib/src/mesa/main/formats.c')
-rw-r--r-- | mesalib/src/mesa/main/formats.c | 196 |
1 files changed, 146 insertions, 50 deletions
diff --git a/mesalib/src/mesa/main/formats.c b/mesalib/src/mesa/main/formats.c index 96317dbf4..cecb70c01 100644 --- a/mesalib/src/mesa/main/formats.c +++ b/mesalib/src/mesa/main/formats.c @@ -2516,14 +2516,16 @@ _mesa_format_to_type_and_comps(gl_format format, /** * Check if a gl_format exactly matches a GL formaat/type combination * such that we can use memcpy() from one to the other. - * - * Note: this matching assumes that GL_PACK/UNPACK_SWAP_BYTES is unset. - * + * \param gl_format a MESA_FORMAT_x value + * \param format the user-specified image format + * \param type the user-specified image datatype + * \param swapBytes typically the current pixel pack/unpack byteswap state * \return GL_TRUE if the formats match, GL_FALSE otherwise. */ GLboolean _mesa_format_matches_format_and_type(gl_format gl_format, - GLenum format, GLenum type) + GLenum format, GLenum type, + GLboolean swapBytes) { const GLboolean littleEndian = _mesa_little_endian(); @@ -2543,21 +2545,77 @@ _mesa_format_matches_format_and_type(gl_format gl_format, return GL_FALSE; case MESA_FORMAT_RGBA8888: - return ((format == GL_RGBA && (type == GL_UNSIGNED_INT_8_8_8_8 || - (type == GL_UNSIGNED_BYTE && !littleEndian))) || - (format == GL_ABGR_EXT && (type == GL_UNSIGNED_INT_8_8_8_8_REV || - (type == GL_UNSIGNED_BYTE && littleEndian)))); + if (format == GL_RGBA && type == GL_UNSIGNED_INT_8_8_8_8 && !swapBytes) + return GL_TRUE; + + if (format == GL_RGBA && type == GL_UNSIGNED_INT_8_8_8_8_REV && swapBytes) + return GL_TRUE; + + if (format == GL_RGBA && type == GL_UNSIGNED_BYTE && !littleEndian) + return GL_TRUE; + + if (format == GL_ABGR_EXT && type == GL_UNSIGNED_INT_8_8_8_8_REV + && !swapBytes) + return GL_TRUE; + + if (format == GL_ABGR_EXT && type == GL_UNSIGNED_INT_8_8_8_8 + && swapBytes) + return GL_TRUE; + + if (format == GL_ABGR_EXT && type == GL_UNSIGNED_BYTE && littleEndian) + return GL_TRUE; + + return GL_FALSE; case MESA_FORMAT_RGBA8888_REV: - return ((format == GL_RGBA && type == GL_UNSIGNED_INT_8_8_8_8_REV)); + if (format == GL_RGBA && type == GL_UNSIGNED_INT_8_8_8_8_REV && + !swapBytes) + return GL_TRUE; + + if (format == GL_RGBA && type == GL_UNSIGNED_INT_8_8_8_8 && swapBytes) + return GL_TRUE; + + if (format == GL_RGBA && type == GL_UNSIGNED_BYTE && littleEndian) + return GL_TRUE; + + if (format == GL_ABGR_EXT && type == GL_UNSIGNED_INT_8_8_8_8 && + !swapBytes) + return GL_TRUE; + + if (format == GL_ABGR_EXT && type == GL_UNSIGNED_INT_8_8_8_8_REV && + swapBytes) + return GL_TRUE; + + if (format == GL_ABGR_EXT && type == GL_UNSIGNED_BYTE && !littleEndian) + return GL_TRUE; + + return GL_FALSE; case MESA_FORMAT_ARGB8888: - return ((format == GL_BGRA && (type == GL_UNSIGNED_INT_8_8_8_8_REV || - (type == GL_UNSIGNED_BYTE && littleEndian)))); + if (format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8_REV && + !swapBytes) + return GL_TRUE; + + if (format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8 && swapBytes) + return GL_TRUE; + + if (format == GL_BGRA && type == GL_UNSIGNED_BYTE && littleEndian) + return GL_TRUE; + + return GL_FALSE; case MESA_FORMAT_ARGB8888_REV: - return ((format == GL_BGRA && (type == GL_UNSIGNED_INT_8_8_8_8 || - (type == GL_UNSIGNED_BYTE && !littleEndian)))); + if (format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8 && !swapBytes) + return GL_TRUE; + + if (format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8_REV && + swapBytes) + return GL_TRUE; + + if (format == GL_BGRA && type == GL_UNSIGNED_BYTE && !littleEndian) + return GL_TRUE; + + return GL_FALSE; case MESA_FORMAT_RGBX8888: case MESA_FORMAT_RGBX8888_REV: @@ -2568,13 +2626,14 @@ _mesa_format_matches_format_and_type(gl_format gl_format, return GL_FALSE; case MESA_FORMAT_RGB888: - return format == GL_RGB && type == GL_UNSIGNED_BYTE && littleEndian; + return format == GL_BGR && type == GL_UNSIGNED_BYTE && littleEndian; case MESA_FORMAT_BGR888: - return GL_FALSE; + return format == GL_RGB && type == GL_UNSIGNED_BYTE && littleEndian; case MESA_FORMAT_RGB565: - return format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5; + return format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 && !swapBytes; + case MESA_FORMAT_RGB565_REV: /* Some of the 16-bit MESA_FORMATs that would seem to correspond to * GL_UNSIGNED_SHORT_* are byte-swapped instead of channel-reversed, @@ -2583,15 +2642,20 @@ _mesa_format_matches_format_and_type(gl_format gl_format, return GL_FALSE; case MESA_FORMAT_ARGB4444: - return format == GL_BGRA && type == GL_UNSIGNED_SHORT_4_4_4_4_REV; + return format == GL_BGRA && type == GL_UNSIGNED_SHORT_4_4_4_4_REV && + !swapBytes; + case MESA_FORMAT_ARGB4444_REV: return GL_FALSE; case MESA_FORMAT_RGBA5551: - return format == GL_RGBA && type == GL_UNSIGNED_SHORT_5_5_5_1; + return format == GL_RGBA && type == GL_UNSIGNED_SHORT_5_5_5_1 && + !swapBytes; case MESA_FORMAT_ARGB1555: - return format == GL_BGRA && type == GL_UNSIGNED_SHORT_1_5_5_5_REV; + return format == GL_BGRA && type == GL_UNSIGNED_SHORT_1_5_5_5_REV && + !swapBytes; + case MESA_FORMAT_ARGB1555_REV: return GL_FALSE; @@ -2603,7 +2667,7 @@ _mesa_format_matches_format_and_type(gl_format gl_format, return GL_FALSE; case MESA_FORMAT_AL1616: - return format == GL_LUMINANCE_ALPHA && type == GL_UNSIGNED_SHORT && littleEndian; + return format == GL_LUMINANCE_ALPHA && type == GL_UNSIGNED_SHORT && littleEndian && !swapBytes; case MESA_FORMAT_AL1616_REV: return GL_FALSE; @@ -2613,15 +2677,18 @@ _mesa_format_matches_format_and_type(gl_format gl_format, case MESA_FORMAT_A8: return format == GL_ALPHA && type == GL_UNSIGNED_BYTE; case MESA_FORMAT_A16: - return format == GL_ALPHA && type == GL_UNSIGNED_SHORT && littleEndian; + return format == GL_ALPHA && type == GL_UNSIGNED_SHORT && + littleEndian && !swapBytes; case MESA_FORMAT_L8: return format == GL_LUMINANCE && type == GL_UNSIGNED_BYTE; case MESA_FORMAT_L16: - return format == GL_LUMINANCE && type == GL_UNSIGNED_SHORT && littleEndian; + return format == GL_LUMINANCE && type == GL_UNSIGNED_SHORT && + littleEndian && !swapBytes; case MESA_FORMAT_I8: return format == GL_INTENSITY && type == GL_UNSIGNED_BYTE; case MESA_FORMAT_I16: - return format == GL_INTENSITY && type == GL_UNSIGNED_SHORT && littleEndian; + return format == GL_INTENSITY && type == GL_UNSIGNED_SHORT && + littleEndian && !swapBytes; case MESA_FORMAT_YCBCR: case MESA_FORMAT_YCBCR_REV: @@ -2635,32 +2702,38 @@ _mesa_format_matches_format_and_type(gl_format gl_format, return GL_FALSE; case MESA_FORMAT_R16: - return format == GL_RED && type == GL_UNSIGNED_SHORT && littleEndian; + return format == GL_RED && type == GL_UNSIGNED_SHORT && littleEndian && + !swapBytes; case MESA_FORMAT_RG1616: - return format == GL_RG && type == GL_UNSIGNED_SHORT && littleEndian; + return format == GL_RG && type == GL_UNSIGNED_SHORT && littleEndian && + !swapBytes; case MESA_FORMAT_RG1616_REV: return GL_FALSE; case MESA_FORMAT_ARGB2101010: - return format == GL_BGRA && type == GL_UNSIGNED_INT_2_10_10_10_REV; + return format == GL_BGRA && type == GL_UNSIGNED_INT_2_10_10_10_REV && + !swapBytes; case MESA_FORMAT_Z24_S8: - return format == GL_DEPTH_STENCIL && type == GL_UNSIGNED_INT_24_8; + return format == GL_DEPTH_STENCIL && type == GL_UNSIGNED_INT_24_8 && + !swapBytes; case MESA_FORMAT_Z24_X8: case MESA_FORMAT_S8_Z24: return GL_FALSE; case MESA_FORMAT_Z16: - return format == GL_DEPTH_COMPONENT && type == GL_UNSIGNED_SHORT; + return format == GL_DEPTH_COMPONENT && type == GL_UNSIGNED_SHORT && + !swapBytes; case MESA_FORMAT_X8_Z24: return GL_FALSE; case MESA_FORMAT_Z32: - return format == GL_DEPTH_COMPONENT && type == GL_UNSIGNED_INT; + return format == GL_DEPTH_COMPONENT && type == GL_UNSIGNED_INT && + !swapBytes; case MESA_FORMAT_S8: - return GL_FALSE; + return format == GL_STENCIL_INDEX && type == GL_UNSIGNED_BYTE; case MESA_FORMAT_SRGB8: case MESA_FORMAT_SRGBA8: @@ -2682,44 +2755,44 @@ _mesa_format_matches_format_and_type(gl_format gl_format, return GL_FALSE; case MESA_FORMAT_RGBA_FLOAT32: - return format == GL_RGBA && type == GL_FLOAT; + return format == GL_RGBA && type == GL_FLOAT && !swapBytes; case MESA_FORMAT_RGBA_FLOAT16: - return format == GL_RGBA && type == GL_HALF_FLOAT; + return format == GL_RGBA && type == GL_HALF_FLOAT && !swapBytes; case MESA_FORMAT_RGB_FLOAT32: - return format == GL_RGB && type == GL_FLOAT; + return format == GL_RGB && type == GL_FLOAT && !swapBytes; case MESA_FORMAT_RGB_FLOAT16: - return format == GL_RGB && type == GL_HALF_FLOAT; + return format == GL_RGB && type == GL_HALF_FLOAT && !swapBytes; case MESA_FORMAT_ALPHA_FLOAT32: - return format == GL_ALPHA && type == GL_FLOAT; + return format == GL_ALPHA && type == GL_FLOAT && !swapBytes; case MESA_FORMAT_ALPHA_FLOAT16: - return format == GL_ALPHA && type == GL_HALF_FLOAT; + return format == GL_ALPHA && type == GL_HALF_FLOAT && !swapBytes; case MESA_FORMAT_LUMINANCE_FLOAT32: - return format == GL_LUMINANCE && type == GL_FLOAT; + return format == GL_LUMINANCE && type == GL_FLOAT && !swapBytes; case MESA_FORMAT_LUMINANCE_FLOAT16: - return format == GL_LUMINANCE && type == GL_HALF_FLOAT; + return format == GL_LUMINANCE && type == GL_HALF_FLOAT && !swapBytes; case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32: - return format == GL_LUMINANCE_ALPHA && type == GL_FLOAT; + return format == GL_LUMINANCE_ALPHA && type == GL_FLOAT && !swapBytes; case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16: - return format == GL_LUMINANCE_ALPHA && type == GL_HALF_FLOAT; + return format == GL_LUMINANCE_ALPHA && type == GL_HALF_FLOAT && !swapBytes; case MESA_FORMAT_INTENSITY_FLOAT32: - return format == GL_INTENSITY && type == GL_FLOAT; + return format == GL_INTENSITY && type == GL_FLOAT && !swapBytes; case MESA_FORMAT_INTENSITY_FLOAT16: - return format == GL_INTENSITY && type == GL_HALF_FLOAT; + return format == GL_INTENSITY && type == GL_HALF_FLOAT && !swapBytes; case MESA_FORMAT_R_FLOAT32: - return format == GL_RED && type == GL_FLOAT; + return format == GL_RED && type == GL_FLOAT && !swapBytes; case MESA_FORMAT_R_FLOAT16: - return format == GL_RED && type == GL_HALF_FLOAT; + return format == GL_RED && type == GL_HALF_FLOAT && !swapBytes; case MESA_FORMAT_RG_FLOAT32: - return format == GL_RG && type == GL_FLOAT; + return format == GL_RG && type == GL_FLOAT && !swapBytes; case MESA_FORMAT_RG_FLOAT16: - return format == GL_RG && type == GL_HALF_FLOAT; + return format == GL_RG && type == GL_HALF_FLOAT && !swapBytes; /* FINISHME: What do we want to do for GL_EXT_texture_integer? */ case MESA_FORMAT_ALPHA_UINT8: @@ -2786,8 +2859,26 @@ _mesa_format_matches_format_and_type(gl_format gl_format, case MESA_FORMAT_SIGNED_R8: case MESA_FORMAT_SIGNED_RG88_REV: case MESA_FORMAT_SIGNED_RGBX8888: + return GL_FALSE; + case MESA_FORMAT_SIGNED_RGBA8888: + if (format == GL_RGBA && type == GL_BYTE && !littleEndian) + return GL_TRUE; + + if (format == GL_ABGR_EXT && type == GL_BYTE && littleEndian) + return GL_TRUE; + + return GL_FALSE; + case MESA_FORMAT_SIGNED_RGBA8888_REV: + if (format == GL_RGBA && type == GL_BYTE && littleEndian) + return GL_TRUE; + + if (format == GL_ABGR_EXT && type == GL_BYTE && !littleEndian) + return GL_TRUE; + + return GL_FALSE; + case MESA_FORMAT_SIGNED_R16: case MESA_FORMAT_SIGNED_GR1616: case MESA_FORMAT_SIGNED_RGB_16: @@ -2823,15 +2914,20 @@ _mesa_format_matches_format_and_type(gl_format gl_format, return GL_FALSE; case MESA_FORMAT_ARGB2101010_UINT: - return GL_FALSE; + return (format == GL_BGRA_INTEGER_EXT && + type == GL_UNSIGNED_INT_2_10_10_10_REV && + !swapBytes); case MESA_FORMAT_RGB9_E5_FLOAT: - return format == GL_RGB && type == GL_UNSIGNED_INT_5_9_9_9_REV; + return format == GL_RGB && type == GL_UNSIGNED_INT_5_9_9_9_REV && + !swapBytes; + case MESA_FORMAT_R11_G11_B10_FLOAT: - return format == GL_RGB && type == GL_UNSIGNED_INT_10F_11F_11F_REV; + return format == GL_RGB && type == GL_UNSIGNED_INT_10F_11F_11F_REV && + !swapBytes; case MESA_FORMAT_Z32_FLOAT: - return format == GL_DEPTH_COMPONENT && type == GL_FLOAT; + return format == GL_DEPTH_COMPONENT && type == GL_FLOAT && !swapBytes; case MESA_FORMAT_Z32_FLOAT_X24S8: return GL_FALSE; |