aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-07-14 09:02:09 +0200
committermarha <marha@users.sourceforge.net>2011-07-14 09:02:09 +0200
commitd03a5f20114203fd00e0004659fd2617f4c03a32 (patch)
tree769d9c09953195385ac9c19aa31a1303b462d2d6 /mesalib/src
parent3b47b2c35227184c0eb6dcf6dee8b79c4f9d4474 (diff)
downloadvcxsrv-d03a5f20114203fd00e0004659fd2617f4c03a32.tar.gz
vcxsrv-d03a5f20114203fd00e0004659fd2617f4c03a32.tar.bz2
vcxsrv-d03a5f20114203fd00e0004659fd2617f4c03a32.zip
mesa xserver git update 14 july 2011
Diffstat (limited to 'mesalib/src')
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format.csv530
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format_yuv.c2229
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format_yuv.h581
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_upload_mgr.c2
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_video.h75
-rw-r--r--mesalib/src/mesa/main/texfetch_tmp.h6
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_condrender.c5
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_queryobj.c363
-rw-r--r--mesalib/src/mesa/state_tracker/st_context.c3
9 files changed, 2081 insertions, 1713 deletions
diff --git a/mesalib/src/gallium/auxiliary/util/u_format.csv b/mesalib/src/gallium/auxiliary/util/u_format.csv
index 00c24cc81..347e2beb8 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format.csv
+++ b/mesalib/src/gallium/auxiliary/util/u_format.csv
@@ -1,261 +1,269 @@
-###########################################################################
-#
-# Copyright 2009-2010 VMware, Inc.
-# All Rights Reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sub license, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice (including the
-# next paragraph) shall be included in all copies or substantial portions
-# of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
-# IN NO EVENT SHALL THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR
-# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-###########################################################################
-
-# This CSV file has the input data for u_format.h's struct
-# util_format_description.
-#
-# Each format entry contains:
-# - name, per enum pipe_format
-# - layout, per enum util_format_layout, in shortened lower caps
-# - pixel block's width
-# - pixel block's height
-# - channel encoding (only meaningful for plain layout), containing for each
-# channel the following information:
-# - type, one of
-# - 'x': void
-# - 'u': unsigned
-# - 's': signed
-# - 'h': fixed
-# - 'f': FLOAT
-# - optionally followed by 'n' if it is normalized
-# - number of bits
-# - channel swizzle
-# - color space: rgb, yub, sz
-#
-# See also:
-# - http://msdn.microsoft.com/en-us/library/bb172558.aspx (D3D9)
-# - http://msdn.microsoft.com/en-us/library/bb205073.aspx#mapping_texture_formats (D3D9 -> D3D10)
-# - http://msdn.microsoft.com/en-us/library/bb173059.aspx (D3D10)
-#
-# Note that GL doesn't really specify the layout of internal formats. See
-# OpenGL 2.1 specification, Table 3.16, on the "Correspondence of sized
-# internal formats to base in- ternal formats, and desired component
-# resolutions for each sized internal format."
-
-# None
-# Described as regular uint_8 bytes, i.e. PIPE_FORMAT_R8_USCALED
-PIPE_FORMAT_NONE , plain, 1, 1, u8 , , , , x001, rgb
-
-# Typical rendertarget formats
-PIPE_FORMAT_B8G8R8A8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , zyxw, rgb
-PIPE_FORMAT_B8G8R8X8_UNORM , plain, 1, 1, un8 , un8 , un8 , x8 , zyx1, rgb
-PIPE_FORMAT_A8R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, rgb
-PIPE_FORMAT_X8R8G8B8_UNORM , plain, 1, 1, x8 , un8 , un8 , un8 , yzw1, rgb
-PIPE_FORMAT_A8B8G8R8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, rgb
-PIPE_FORMAT_X8B8G8R8_UNORM , plain, 1, 1, x8 , un8 , un8 , un8 , wzy1, rgb
-# PIPE_FORMAT_R8G8B8A8_UNORM is below
-PIPE_FORMAT_R8G8B8X8_UNORM , plain, 1, 1, un8 , un8 , un8 , x8 , xyz1, rgb
-PIPE_FORMAT_B5G5R5X1_UNORM , plain, 1, 1, un5 , un5 , un5 , x1 , zyx1, rgb
-PIPE_FORMAT_B5G5R5A1_UNORM , plain, 1, 1, un5 , un5 , un5 , un1 , zyxw, rgb
-PIPE_FORMAT_B4G4R4A4_UNORM , plain, 1, 1, un4 , un4 , un4 , un4 , zyxw, rgb
-PIPE_FORMAT_B4G4R4X4_UNORM , plain, 1, 1, un4 , un4 , un4 , x4 , zyx1, rgb
-PIPE_FORMAT_B5G6R5_UNORM , plain, 1, 1, un5 , un6 , un5 , , zyx1, rgb
-PIPE_FORMAT_R10G10B10A2_UNORM , plain, 1, 1, un10, un10, un10, un2 , xyzw, rgb
-PIPE_FORMAT_B10G10R10A2_UNORM , plain, 1, 1, un10, un10, un10, un2 , zyxw, rgb
-PIPE_FORMAT_B2G3R3_UNORM , plain, 1, 1, un2 , un3 , un3 , , zyx1, rgb
-
-# Luminance/Intensity/Alpha formats
-PIPE_FORMAT_L8_UNORM , plain, 1, 1, un8 , , , , xxx1, rgb
-PIPE_FORMAT_A8_UNORM , plain, 1, 1, un8 , , , , 000x, rgb
-PIPE_FORMAT_I8_UNORM , plain, 1, 1, un8 , , , , xxxx, rgb
-PIPE_FORMAT_L4A4_UNORM , plain, 1, 1, un4 , un4 , , , xxxy, rgb
-PIPE_FORMAT_L8A8_UNORM , plain, 1, 1, un8 , un8 , , , xxxy, rgb
-PIPE_FORMAT_L16_UNORM , plain, 1, 1, un16, , , , xxx1, rgb
-PIPE_FORMAT_A16_UNORM , plain, 1, 1, un16, , , , 000x, rgb
-PIPE_FORMAT_I16_UNORM , plain, 1, 1, un16, , , , xxxx, rgb
-PIPE_FORMAT_L16A16_UNORM , plain, 1, 1, un16, un16, , , xxxy, rgb
-PIPE_FORMAT_A8_SNORM , plain, 1, 1, sn8 , , , , 000x, rgb
-PIPE_FORMAT_L8_SNORM , plain, 1, 1, sn8 , , , , xxx1, rgb
-PIPE_FORMAT_L8A8_SNORM , plain, 1, 1, sn8 , sn8 , , , xxxy, rgb
-PIPE_FORMAT_I8_SNORM , plain, 1, 1, sn8 , , , , xxxx, rgb
-PIPE_FORMAT_A16_SNORM , plain, 1, 1, sn16, , , , 000x, rgb
-PIPE_FORMAT_L16_SNORM , plain, 1, 1, sn16, , , , xxx1, rgb
-PIPE_FORMAT_L16A16_SNORM , plain, 1, 1, sn16, sn16, , , xxxy, rgb
-PIPE_FORMAT_I16_SNORM , plain, 1, 1, sn16, , , , xxxx, rgb
-PIPE_FORMAT_A16_FLOAT , plain, 1, 1, f16 , , , , 000x, rgb
-PIPE_FORMAT_L16_FLOAT , plain, 1, 1, f16 , , , , xxx1, rgb
-PIPE_FORMAT_L16A16_FLOAT , plain, 1, 1, f16 , f16 , , , xxxy, rgb
-PIPE_FORMAT_I16_FLOAT , plain, 1, 1, f16 , , , , xxxx, rgb
-PIPE_FORMAT_A32_FLOAT , plain, 1, 1, f32 , , , , 000x, rgb
-PIPE_FORMAT_L32_FLOAT , plain, 1, 1, f32 , , , , xxx1, rgb
-PIPE_FORMAT_L32A32_FLOAT , plain, 1, 1, f32 , f32 , , , xxxy, rgb
-PIPE_FORMAT_I32_FLOAT , plain, 1, 1, f32 , , , , xxxx, rgb
-
-# SRGB formats
-PIPE_FORMAT_L8_SRGB , plain, 1, 1, un8 , , , , xxx1, srgb
-PIPE_FORMAT_L8A8_SRGB , plain, 1, 1, un8 , un8 , , , xxxy, srgb
-PIPE_FORMAT_R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , , xyz1, srgb
-PIPE_FORMAT_R8G8B8A8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , xyzw, srgb
-PIPE_FORMAT_A8B8G8R8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, srgb
-PIPE_FORMAT_X8B8G8R8_SRGB , plain, 1, 1, x8 , un8 , un8 , un8 , wzy1, srgb
-PIPE_FORMAT_B8G8R8A8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , zyxw, srgb
-PIPE_FORMAT_B8G8R8X8_SRGB , plain, 1, 1, un8 , un8 , un8 , x8 , zyx1, srgb
-PIPE_FORMAT_A8R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, srgb
-PIPE_FORMAT_X8R8G8B8_SRGB , plain, 1, 1, x8 , un8 , un8 , un8 , yzw1, srgb
-
-# Mixed-sign formats (typically used for bump map textures)
-PIPE_FORMAT_R8SG8SB8UX8U_NORM , plain, 1, 1, sn8 , sn8 , un8 , x8 , xyz1, rgb
-PIPE_FORMAT_R10SG10SB10SA2U_NORM , plain, 1, 1, sn10, sn10, sn10, un2 , xyzw, rgb
-PIPE_FORMAT_R5SG5SB6U_NORM , plain, 1, 1, sn5 , sn5 , un6 , , xyz1, rgb
-
-# Depth-stencil formats
-PIPE_FORMAT_S8_USCALED , plain, 1, 1, u8 , , , , _x__, zs
-PIPE_FORMAT_Z16_UNORM , plain, 1, 1, un16, , , , x___, zs
-PIPE_FORMAT_Z32_UNORM , plain, 1, 1, un32, , , , x___, zs
-PIPE_FORMAT_Z32_FLOAT , plain, 1, 1, f32 , , , , x___, zs
-PIPE_FORMAT_Z24_UNORM_S8_USCALED , plain, 1, 1, un24, u8 , , , xy__, zs
-PIPE_FORMAT_S8_USCALED_Z24_UNORM , plain, 1, 1, u8 , un24, , , yx__, zs
-PIPE_FORMAT_X24S8_USCALED , plain, 1, 1, x24, u8 , , , _y__, zs
-PIPE_FORMAT_S8X24_USCALED , plain, 1, 1, u8 , x24 , , , _x__, zs
-PIPE_FORMAT_Z24X8_UNORM , plain, 1, 1, un24, x8 , , , x___, zs
-PIPE_FORMAT_X8Z24_UNORM , plain, 1, 1, x8 , un24, , , y___, zs
-PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED , plain, 1, 1, f32, u8 , x24 , , xy__, zs
-PIPE_FORMAT_X32_S8X24_USCALED , plain, 1, 1, x32, u8 , x24 , , _y__, zs
-
-# YUV formats
-# http://www.fourcc.org/yuv.php#UYVY
-PIPE_FORMAT_UYVY , subsampled, 2, 1, x32 , , , , xyz1, yuv
-# http://www.fourcc.org/yuv.php#YUYV (a.k.a http://www.fourcc.org/yuv.php#YUY2)
-PIPE_FORMAT_YUYV , subsampled, 2, 1, x32 , , , , xyz1, yuv
-# same subsampling but with rgb channels
-PIPE_FORMAT_R8G8_B8G8_UNORM , subsampled, 2, 1, x32 , , , , xyz1, rgb
-PIPE_FORMAT_G8R8_G8B8_UNORM , subsampled, 2, 1, x32 , , , , xyz1, rgb
-
-# some special formats not fitting anywhere else
-PIPE_FORMAT_R10G10B10A2_USCALED , plain, 1, 1, u10 , u10 , u10 , u2 , xyzw, rgb
-PIPE_FORMAT_R11G11B10_FLOAT , other, 1, 1, x32 , , , , xyz1, rgb
-PIPE_FORMAT_R9G9B9E5_FLOAT , other, 1, 1, x32 , , , , xyz1, rgb
-PIPE_FORMAT_R1_UNORM , other, 8, 1, x8 , , , , x001, rgb
-# A.k.a. D3DFMT_CxV8U8
-PIPE_FORMAT_R8G8Bx_SNORM , other, 1, 1, sn8 , sn8 , , , xyz1, rgb
-
-# Compressed formats
-# - http://en.wikipedia.org/wiki/S3_Texture_Compression
-# - http://www.opengl.org/registry/specs/EXT/texture_compression_s3tc.txt
-# - http://www.opengl.org/registry/specs/ARB/texture_compression_rgtc.txt
-# - http://www.opengl.org/registry/specs/EXT/texture_compression_latc.txt
-# - http://msdn.microsoft.com/en-us/library/bb694531.aspx
-PIPE_FORMAT_DXT1_RGB , s3tc, 4, 4, x64 , , , , xyz1, rgb
-PIPE_FORMAT_DXT1_RGBA , s3tc, 4, 4, x64 , , , , xyzw, rgb
-PIPE_FORMAT_DXT3_RGBA , s3tc, 4, 4, x128, , , , xyzw, rgb
-PIPE_FORMAT_DXT5_RGBA , s3tc, 4, 4, x128, , , , xyzw, rgb
-PIPE_FORMAT_DXT1_SRGB , s3tc, 4, 4, x64 , , , , xyz1, srgb
-PIPE_FORMAT_DXT1_SRGBA , s3tc, 4, 4, x64 , , , , xyzw, srgb
-PIPE_FORMAT_DXT3_SRGBA , s3tc, 4, 4, x128, , , , xyzw, srgb
-PIPE_FORMAT_DXT5_SRGBA , s3tc, 4, 4, x128, , , , xyzw, srgb
-
-PIPE_FORMAT_RGTC1_UNORM , rgtc, 4, 4, x64, , , , x001, rgb
-PIPE_FORMAT_RGTC1_SNORM , rgtc, 4, 4, x64, , , , x001, rgb
-PIPE_FORMAT_RGTC2_UNORM , rgtc, 4, 4, x128, , , , xy01, rgb
-PIPE_FORMAT_RGTC2_SNORM , rgtc, 4, 4, x128, , , , xy01, rgb
-
-PIPE_FORMAT_LATC1_UNORM , rgtc, 4, 4, x64, , , , xxx1, rgb
-PIPE_FORMAT_LATC1_SNORM , rgtc, 4, 4, x64, , , , xxx1, rgb
-PIPE_FORMAT_LATC2_UNORM , rgtc, 4, 4, x128, , , , xxxy, rgb
-PIPE_FORMAT_LATC2_SNORM , rgtc, 4, 4, x128, , , , xxxy, rgb
-
-# Straightforward D3D10-like formats (also used for
-# vertex buffer element description)
-#
-# See also:
-# - src/gallium/auxiliary/translate/translate_generic.c
-# - src/mesa/state_tracker/st_draw.c
-PIPE_FORMAT_R64_FLOAT , plain, 1, 1, f64 , , , , x001, rgb
-PIPE_FORMAT_R64G64_FLOAT , plain, 1, 1, f64 , f64 , , , xy01, rgb
-PIPE_FORMAT_R64G64B64_FLOAT , plain, 1, 1, f64 , f64 , f64 , , xyz1, rgb
-PIPE_FORMAT_R64G64B64A64_FLOAT , plain, 1, 1, f64 , f64 , f64 , f64 , xyzw, rgb
-PIPE_FORMAT_R32_FLOAT , plain, 1, 1, f32 , , , , x001, rgb
-PIPE_FORMAT_R32G32_FLOAT , plain, 1, 1, f32 , f32 , , , xy01, rgb
-PIPE_FORMAT_R32G32B32_FLOAT , plain, 1, 1, f32 , f32 , f32 , , xyz1, rgb
-PIPE_FORMAT_R32G32B32A32_FLOAT , plain, 1, 1, f32 , f32 , f32 , f32 , xyzw, rgb
-PIPE_FORMAT_R32_UNORM , plain, 1, 1, un32, , , , x001, rgb
-PIPE_FORMAT_R32G32_UNORM , plain, 1, 1, un32, un32, , , xy01, rgb
-PIPE_FORMAT_R32G32B32_UNORM , plain, 1, 1, un32, un32, un32, , xyz1, rgb
-PIPE_FORMAT_R32G32B32A32_UNORM , plain, 1, 1, un32, un32, un32, un32, xyzw, rgb
-PIPE_FORMAT_R32_USCALED , plain, 1, 1, u32 , , , , x001, rgb
-PIPE_FORMAT_R32G32_USCALED , plain, 1, 1, u32 , u32 , , , xy01, rgb
-PIPE_FORMAT_R32G32B32_USCALED , plain, 1, 1, u32 , u32 , u32 , , xyz1, rgb
-PIPE_FORMAT_R32G32B32A32_USCALED , plain, 1, 1, u32 , u32 , u32 , u32 , xyzw, rgb
-PIPE_FORMAT_R32_SNORM , plain, 1, 1, sn32, , , , x001, rgb
-PIPE_FORMAT_R32G32_SNORM , plain, 1, 1, sn32, sn32, , , xy01, rgb
-PIPE_FORMAT_R32G32B32_SNORM , plain, 1, 1, sn32, sn32, sn32, , xyz1, rgb
-PIPE_FORMAT_R32G32B32A32_SNORM , plain, 1, 1, sn32, sn32, sn32, sn32, xyzw, rgb
-PIPE_FORMAT_R32_SSCALED , plain, 1, 1, s32 , , , , x001, rgb
-PIPE_FORMAT_R32G32_SSCALED , plain, 1, 1, s32 , s32 , , , xy01, rgb
-PIPE_FORMAT_R32G32B32_SSCALED , plain, 1, 1, s32 , s32 , s32 , , xyz1, rgb
-PIPE_FORMAT_R32G32B32A32_SSCALED , plain, 1, 1, s32 , s32 , s32 , s32 , xyzw, rgb
-PIPE_FORMAT_R16_FLOAT , plain, 1, 1, f16 , , , , x001, rgb
-PIPE_FORMAT_R16G16_FLOAT , plain, 1, 1, f16 , f16 , , , xy01, rgb
-PIPE_FORMAT_R16G16B16_FLOAT , plain, 1, 1, f16 , f16 , f16 , , xyz1, rgb
-PIPE_FORMAT_R16G16B16A16_FLOAT , plain, 1, 1, f16 , f16 , f16 , f16 , xyzw, rgb
-PIPE_FORMAT_R16_UNORM , plain, 1, 1, un16, , , , x001, rgb
-PIPE_FORMAT_R16G16_UNORM , plain, 1, 1, un16, un16, , , xy01, rgb
-PIPE_FORMAT_R16G16B16_UNORM , plain, 1, 1, un16, un16, un16, , xyz1, rgb
-PIPE_FORMAT_R16G16B16A16_UNORM , plain, 1, 1, un16, un16, un16, un16, xyzw, rgb
-PIPE_FORMAT_R16_USCALED , plain, 1, 1, u16 , , , , x001, rgb
-PIPE_FORMAT_R16G16_USCALED , plain, 1, 1, u16 , u16 , , , xy01, rgb
-PIPE_FORMAT_R16G16B16_USCALED , plain, 1, 1, u16 , u16 , u16 , , xyz1, rgb
-PIPE_FORMAT_R16G16B16A16_USCALED , plain, 1, 1, u16 , u16 , u16 , u16 , xyzw, rgb
-PIPE_FORMAT_R16_SNORM , plain, 1, 1, sn16, , , , x001, rgb
-PIPE_FORMAT_R16G16_SNORM , plain, 1, 1, sn16, sn16, , , xy01, rgb
-PIPE_FORMAT_R16G16B16_SNORM , plain, 1, 1, sn16, sn16, sn16, , xyz1, rgb
-PIPE_FORMAT_R16G16B16A16_SNORM , plain, 1, 1, sn16, sn16, sn16, sn16, xyzw, rgb
-PIPE_FORMAT_R16_SSCALED , plain, 1, 1, s16 , , , , x001, rgb
-PIPE_FORMAT_R16G16_SSCALED , plain, 1, 1, s16 , s16 , , , xy01, rgb
-PIPE_FORMAT_R16G16B16_SSCALED , plain, 1, 1, s16 , s16 , s16 , , xyz1, rgb
-PIPE_FORMAT_R16G16B16A16_SSCALED , plain, 1, 1, s16 , s16 , s16 , s16 , xyzw, rgb
-PIPE_FORMAT_R8_UNORM , plain, 1, 1, un8 , , , , x001, rgb
-PIPE_FORMAT_R8G8_UNORM , plain, 1, 1, un8 , un8 , , , xy01, rgb
-PIPE_FORMAT_R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , , xyz1, rgb
-PIPE_FORMAT_R8G8B8A8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , xyzw, rgb
-PIPE_FORMAT_R8_USCALED , plain, 1, 1, u8 , , , , x001, rgb
-PIPE_FORMAT_R8G8_USCALED , plain, 1, 1, u8 , u8 , , , xy01, rgb
-PIPE_FORMAT_R8G8B8_USCALED , plain, 1, 1, u8 , u8 , u8 , , xyz1, rgb
-PIPE_FORMAT_R8G8B8A8_USCALED , plain, 1, 1, u8 , u8 , u8 , u8 , xyzw, rgb
-PIPE_FORMAT_R8_SNORM , plain, 1, 1, sn8 , , , , x001, rgb
-PIPE_FORMAT_R8G8_SNORM , plain, 1, 1, sn8 , sn8 , , , xy01, rgb
-PIPE_FORMAT_R8G8B8_SNORM , plain, 1, 1, sn8 , sn8 , sn8 , , xyz1, rgb
-PIPE_FORMAT_R8G8B8A8_SNORM , plain, 1, 1, sn8 , sn8 , sn8 , sn8 , xyzw, rgb
-PIPE_FORMAT_R8_SSCALED , plain, 1, 1, s8 , , , , x001, rgb
-PIPE_FORMAT_R8G8_SSCALED , plain, 1, 1, s8 , s8 , , , xy01, rgb
-PIPE_FORMAT_R8G8B8_SSCALED , plain, 1, 1, s8 , s8 , s8 , , xyz1, rgb
-PIPE_FORMAT_R8G8B8A8_SSCALED , plain, 1, 1, s8 , s8 , s8 , s8 , xyzw, rgb
-
-# GL-specific vertex buffer element formats
-# A.k.a. GL_FIXED
-PIPE_FORMAT_R32_FIXED , plain, 1, 1, h32 , , , , x001, rgb
-PIPE_FORMAT_R32G32_FIXED , plain, 1, 1, h32 , h32 , , , xy01, rgb
-PIPE_FORMAT_R32G32B32_FIXED , plain, 1, 1, h32 , h32 , h32 , , xyz1, rgb
-PIPE_FORMAT_R32G32B32A32_FIXED , plain, 1, 1, h32 , h32 , h32 , h32 , xyzw, rgb
-
-# D3D9-specific vertex buffer element formats
-# See also:
-# - http://msdn.microsoft.com/en-us/library/bb172533.aspx
-# A.k.a. D3DDECLTYPE_UDEC3
-PIPE_FORMAT_R10G10B10X2_USCALED , plain, 1, 1, u10 , u10 , u10 , x2 , xyz1, rgb
-# A.k.a. D3DDECLTYPE_DEC3N
-PIPE_FORMAT_R10G10B10X2_SNORM , plain, 1, 1, sn10, sn10, sn10 , x2 , xyz1, rgb
+###########################################################################
+#
+# Copyright 2009-2010 VMware, Inc.
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sub license, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice (including the
+# next paragraph) shall be included in all copies or substantial portions
+# of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR
+# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+###########################################################################
+
+# This CSV file has the input data for u_format.h's struct
+# util_format_description.
+#
+# Each format entry contains:
+# - name, per enum pipe_format
+# - layout, per enum util_format_layout, in shortened lower caps
+# - pixel block's width
+# - pixel block's height
+# - channel encoding (only meaningful for plain layout), containing for each
+# channel the following information:
+# - type, one of
+# - 'x': void
+# - 'u': unsigned
+# - 's': signed
+# - 'h': fixed
+# - 'f': FLOAT
+# - optionally followed by 'n' if it is normalized
+# - number of bits
+# - channel swizzle
+# - color space: rgb, yub, sz
+#
+# See also:
+# - http://msdn.microsoft.com/en-us/library/bb172558.aspx (D3D9)
+# - http://msdn.microsoft.com/en-us/library/bb205073.aspx#mapping_texture_formats (D3D9 -> D3D10)
+# - http://msdn.microsoft.com/en-us/library/bb173059.aspx (D3D10)
+#
+# Note that GL doesn't really specify the layout of internal formats. See
+# OpenGL 2.1 specification, Table 3.16, on the "Correspondence of sized
+# internal formats to base in- ternal formats, and desired component
+# resolutions for each sized internal format."
+
+# None
+# Described as regular uint_8 bytes, i.e. PIPE_FORMAT_R8_USCALED
+PIPE_FORMAT_NONE , plain, 1, 1, u8 , , , , x001, rgb
+
+# Typical rendertarget formats
+PIPE_FORMAT_B8G8R8A8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , zyxw, rgb
+PIPE_FORMAT_B8G8R8X8_UNORM , plain, 1, 1, un8 , un8 , un8 , x8 , zyx1, rgb
+PIPE_FORMAT_A8R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, rgb
+PIPE_FORMAT_X8R8G8B8_UNORM , plain, 1, 1, x8 , un8 , un8 , un8 , yzw1, rgb
+PIPE_FORMAT_A8B8G8R8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, rgb
+PIPE_FORMAT_X8B8G8R8_UNORM , plain, 1, 1, x8 , un8 , un8 , un8 , wzy1, rgb
+# PIPE_FORMAT_R8G8B8A8_UNORM is below
+PIPE_FORMAT_R8G8B8X8_UNORM , plain, 1, 1, un8 , un8 , un8 , x8 , xyz1, rgb
+PIPE_FORMAT_B5G5R5X1_UNORM , plain, 1, 1, un5 , un5 , un5 , x1 , zyx1, rgb
+PIPE_FORMAT_B5G5R5A1_UNORM , plain, 1, 1, un5 , un5 , un5 , un1 , zyxw, rgb
+PIPE_FORMAT_B4G4R4A4_UNORM , plain, 1, 1, un4 , un4 , un4 , un4 , zyxw, rgb
+PIPE_FORMAT_B4G4R4X4_UNORM , plain, 1, 1, un4 , un4 , un4 , x4 , zyx1, rgb
+PIPE_FORMAT_B5G6R5_UNORM , plain, 1, 1, un5 , un6 , un5 , , zyx1, rgb
+PIPE_FORMAT_R10G10B10A2_UNORM , plain, 1, 1, un10, un10, un10, un2 , xyzw, rgb
+PIPE_FORMAT_B10G10R10A2_UNORM , plain, 1, 1, un10, un10, un10, un2 , zyxw, rgb
+PIPE_FORMAT_B2G3R3_UNORM , plain, 1, 1, un2 , un3 , un3 , , zyx1, rgb
+
+# Luminance/Intensity/Alpha formats
+PIPE_FORMAT_L8_UNORM , plain, 1, 1, un8 , , , , xxx1, rgb
+PIPE_FORMAT_A8_UNORM , plain, 1, 1, un8 , , , , 000x, rgb
+PIPE_FORMAT_I8_UNORM , plain, 1, 1, un8 , , , , xxxx, rgb
+PIPE_FORMAT_L4A4_UNORM , plain, 1, 1, un4 , un4 , , , xxxy, rgb
+PIPE_FORMAT_L8A8_UNORM , plain, 1, 1, un8 , un8 , , , xxxy, rgb
+PIPE_FORMAT_L16_UNORM , plain, 1, 1, un16, , , , xxx1, rgb
+PIPE_FORMAT_A16_UNORM , plain, 1, 1, un16, , , , 000x, rgb
+PIPE_FORMAT_I16_UNORM , plain, 1, 1, un16, , , , xxxx, rgb
+PIPE_FORMAT_L16A16_UNORM , plain, 1, 1, un16, un16, , , xxxy, rgb
+PIPE_FORMAT_A8_SNORM , plain, 1, 1, sn8 , , , , 000x, rgb
+PIPE_FORMAT_L8_SNORM , plain, 1, 1, sn8 , , , , xxx1, rgb
+PIPE_FORMAT_L8A8_SNORM , plain, 1, 1, sn8 , sn8 , , , xxxy, rgb
+PIPE_FORMAT_I8_SNORM , plain, 1, 1, sn8 , , , , xxxx, rgb
+PIPE_FORMAT_A16_SNORM , plain, 1, 1, sn16, , , , 000x, rgb
+PIPE_FORMAT_L16_SNORM , plain, 1, 1, sn16, , , , xxx1, rgb
+PIPE_FORMAT_L16A16_SNORM , plain, 1, 1, sn16, sn16, , , xxxy, rgb
+PIPE_FORMAT_I16_SNORM , plain, 1, 1, sn16, , , , xxxx, rgb
+PIPE_FORMAT_A16_FLOAT , plain, 1, 1, f16 , , , , 000x, rgb
+PIPE_FORMAT_L16_FLOAT , plain, 1, 1, f16 , , , , xxx1, rgb
+PIPE_FORMAT_L16A16_FLOAT , plain, 1, 1, f16 , f16 , , , xxxy, rgb
+PIPE_FORMAT_I16_FLOAT , plain, 1, 1, f16 , , , , xxxx, rgb
+PIPE_FORMAT_A32_FLOAT , plain, 1, 1, f32 , , , , 000x, rgb
+PIPE_FORMAT_L32_FLOAT , plain, 1, 1, f32 , , , , xxx1, rgb
+PIPE_FORMAT_L32A32_FLOAT , plain, 1, 1, f32 , f32 , , , xxxy, rgb
+PIPE_FORMAT_I32_FLOAT , plain, 1, 1, f32 , , , , xxxx, rgb
+
+# SRGB formats
+PIPE_FORMAT_L8_SRGB , plain, 1, 1, un8 , , , , xxx1, srgb
+PIPE_FORMAT_L8A8_SRGB , plain, 1, 1, un8 , un8 , , , xxxy, srgb
+PIPE_FORMAT_R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , , xyz1, srgb
+PIPE_FORMAT_R8G8B8A8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , xyzw, srgb
+PIPE_FORMAT_A8B8G8R8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, srgb
+PIPE_FORMAT_X8B8G8R8_SRGB , plain, 1, 1, x8 , un8 , un8 , un8 , wzy1, srgb
+PIPE_FORMAT_B8G8R8A8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , zyxw, srgb
+PIPE_FORMAT_B8G8R8X8_SRGB , plain, 1, 1, un8 , un8 , un8 , x8 , zyx1, srgb
+PIPE_FORMAT_A8R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, srgb
+PIPE_FORMAT_X8R8G8B8_SRGB , plain, 1, 1, x8 , un8 , un8 , un8 , yzw1, srgb
+
+# Mixed-sign formats (typically used for bump map textures)
+PIPE_FORMAT_R8SG8SB8UX8U_NORM , plain, 1, 1, sn8 , sn8 , un8 , x8 , xyz1, rgb
+PIPE_FORMAT_R10SG10SB10SA2U_NORM , plain, 1, 1, sn10, sn10, sn10, un2 , xyzw, rgb
+PIPE_FORMAT_R5SG5SB6U_NORM , plain, 1, 1, sn5 , sn5 , un6 , , xyz1, rgb
+
+# Depth-stencil formats
+PIPE_FORMAT_S8_USCALED , plain, 1, 1, u8 , , , , _x__, zs
+PIPE_FORMAT_Z16_UNORM , plain, 1, 1, un16, , , , x___, zs
+PIPE_FORMAT_Z32_UNORM , plain, 1, 1, un32, , , , x___, zs
+PIPE_FORMAT_Z32_FLOAT , plain, 1, 1, f32 , , , , x___, zs
+PIPE_FORMAT_Z24_UNORM_S8_USCALED , plain, 1, 1, un24, u8 , , , xy__, zs
+PIPE_FORMAT_S8_USCALED_Z24_UNORM , plain, 1, 1, u8 , un24, , , yx__, zs
+PIPE_FORMAT_X24S8_USCALED , plain, 1, 1, x24, u8 , , , _y__, zs
+PIPE_FORMAT_S8X24_USCALED , plain, 1, 1, u8 , x24 , , , _x__, zs
+PIPE_FORMAT_Z24X8_UNORM , plain, 1, 1, un24, x8 , , , x___, zs
+PIPE_FORMAT_X8Z24_UNORM , plain, 1, 1, x8 , un24, , , y___, zs
+PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED , plain, 1, 1, f32, u8 , x24 , , xy__, zs
+PIPE_FORMAT_X32_S8X24_USCALED , plain, 1, 1, x32, u8 , x24 , , _y__, zs
+
+# YUV formats
+# http://www.fourcc.org/yuv.php#UYVY
+PIPE_FORMAT_UYVY , subsampled, 2, 1, x32 , , , , xyz1, yuv
+# http://www.fourcc.org/yuv.php#YUYV (a.k.a http://www.fourcc.org/yuv.php#YUY2)
+PIPE_FORMAT_YUYV , subsampled, 2, 1, x32 , , , , xyz1, yuv
+# same subsampling but with rgb channels
+PIPE_FORMAT_R8G8_B8G8_UNORM , subsampled, 2, 1, x32 , , , , xyz1, rgb
+PIPE_FORMAT_G8R8_G8B8_UNORM , subsampled, 2, 1, x32 , , , , xyz1, rgb
+
+# some special formats not fitting anywhere else
+PIPE_FORMAT_R10G10B10A2_USCALED , plain, 1, 1, u10 , u10 , u10 , u2 , xyzw, rgb
+PIPE_FORMAT_R11G11B10_FLOAT , other, 1, 1, x32 , , , , xyz1, rgb
+PIPE_FORMAT_R9G9B9E5_FLOAT , other, 1, 1, x32 , , , , xyz1, rgb
+PIPE_FORMAT_R1_UNORM , other, 8, 1, x8 , , , , x001, rgb
+# A.k.a. D3DFMT_CxV8U8
+PIPE_FORMAT_R8G8Bx_SNORM , other, 1, 1, sn8 , sn8 , , , xyz1, rgb
+
+# Compressed formats
+# - http://en.wikipedia.org/wiki/S3_Texture_Compression
+# - http://www.opengl.org/registry/specs/EXT/texture_compression_s3tc.txt
+# - http://www.opengl.org/registry/specs/ARB/texture_compression_rgtc.txt
+# - http://www.opengl.org/registry/specs/EXT/texture_compression_latc.txt
+# - http://msdn.microsoft.com/en-us/library/bb694531.aspx
+PIPE_FORMAT_DXT1_RGB , s3tc, 4, 4, x64 , , , , xyz1, rgb
+PIPE_FORMAT_DXT1_RGBA , s3tc, 4, 4, x64 , , , , xyzw, rgb
+PIPE_FORMAT_DXT3_RGBA , s3tc, 4, 4, x128, , , , xyzw, rgb
+PIPE_FORMAT_DXT5_RGBA , s3tc, 4, 4, x128, , , , xyzw, rgb
+PIPE_FORMAT_DXT1_SRGB , s3tc, 4, 4, x64 , , , , xyz1, srgb
+PIPE_FORMAT_DXT1_SRGBA , s3tc, 4, 4, x64 , , , , xyzw, srgb
+PIPE_FORMAT_DXT3_SRGBA , s3tc, 4, 4, x128, , , , xyzw, srgb
+PIPE_FORMAT_DXT5_SRGBA , s3tc, 4, 4, x128, , , , xyzw, srgb
+
+PIPE_FORMAT_RGTC1_UNORM , rgtc, 4, 4, x64, , , , x001, rgb
+PIPE_FORMAT_RGTC1_SNORM , rgtc, 4, 4, x64, , , , x001, rgb
+PIPE_FORMAT_RGTC2_UNORM , rgtc, 4, 4, x128, , , , xy01, rgb
+PIPE_FORMAT_RGTC2_SNORM , rgtc, 4, 4, x128, , , , xy01, rgb
+
+PIPE_FORMAT_LATC1_UNORM , rgtc, 4, 4, x64, , , , xxx1, rgb
+PIPE_FORMAT_LATC1_SNORM , rgtc, 4, 4, x64, , , , xxx1, rgb
+PIPE_FORMAT_LATC2_UNORM , rgtc, 4, 4, x128, , , , xxxy, rgb
+PIPE_FORMAT_LATC2_SNORM , rgtc, 4, 4, x128, , , , xxxy, rgb
+
+# Straightforward D3D10-like formats (also used for
+# vertex buffer element description)
+#
+# See also:
+# - src/gallium/auxiliary/translate/translate_generic.c
+# - src/mesa/state_tracker/st_draw.c
+PIPE_FORMAT_R64_FLOAT , plain, 1, 1, f64 , , , , x001, rgb
+PIPE_FORMAT_R64G64_FLOAT , plain, 1, 1, f64 , f64 , , , xy01, rgb
+PIPE_FORMAT_R64G64B64_FLOAT , plain, 1, 1, f64 , f64 , f64 , , xyz1, rgb
+PIPE_FORMAT_R64G64B64A64_FLOAT , plain, 1, 1, f64 , f64 , f64 , f64 , xyzw, rgb
+PIPE_FORMAT_R32_FLOAT , plain, 1, 1, f32 , , , , x001, rgb
+PIPE_FORMAT_R32G32_FLOAT , plain, 1, 1, f32 , f32 , , , xy01, rgb
+PIPE_FORMAT_R32G32B32_FLOAT , plain, 1, 1, f32 , f32 , f32 , , xyz1, rgb
+PIPE_FORMAT_R32G32B32A32_FLOAT , plain, 1, 1, f32 , f32 , f32 , f32 , xyzw, rgb
+PIPE_FORMAT_R32_UNORM , plain, 1, 1, un32, , , , x001, rgb
+PIPE_FORMAT_R32G32_UNORM , plain, 1, 1, un32, un32, , , xy01, rgb
+PIPE_FORMAT_R32G32B32_UNORM , plain, 1, 1, un32, un32, un32, , xyz1, rgb
+PIPE_FORMAT_R32G32B32A32_UNORM , plain, 1, 1, un32, un32, un32, un32, xyzw, rgb
+PIPE_FORMAT_R32_USCALED , plain, 1, 1, u32 , , , , x001, rgb
+PIPE_FORMAT_R32G32_USCALED , plain, 1, 1, u32 , u32 , , , xy01, rgb
+PIPE_FORMAT_R32G32B32_USCALED , plain, 1, 1, u32 , u32 , u32 , , xyz1, rgb
+PIPE_FORMAT_R32G32B32A32_USCALED , plain, 1, 1, u32 , u32 , u32 , u32 , xyzw, rgb
+PIPE_FORMAT_R32_SNORM , plain, 1, 1, sn32, , , , x001, rgb
+PIPE_FORMAT_R32G32_SNORM , plain, 1, 1, sn32, sn32, , , xy01, rgb
+PIPE_FORMAT_R32G32B32_SNORM , plain, 1, 1, sn32, sn32, sn32, , xyz1, rgb
+PIPE_FORMAT_R32G32B32A32_SNORM , plain, 1, 1, sn32, sn32, sn32, sn32, xyzw, rgb
+PIPE_FORMAT_R32_SSCALED , plain, 1, 1, s32 , , , , x001, rgb
+PIPE_FORMAT_R32G32_SSCALED , plain, 1, 1, s32 , s32 , , , xy01, rgb
+PIPE_FORMAT_R32G32B32_SSCALED , plain, 1, 1, s32 , s32 , s32 , , xyz1, rgb
+PIPE_FORMAT_R32G32B32A32_SSCALED , plain, 1, 1, s32 , s32 , s32 , s32 , xyzw, rgb
+PIPE_FORMAT_R16_FLOAT , plain, 1, 1, f16 , , , , x001, rgb
+PIPE_FORMAT_R16G16_FLOAT , plain, 1, 1, f16 , f16 , , , xy01, rgb
+PIPE_FORMAT_R16G16B16_FLOAT , plain, 1, 1, f16 , f16 , f16 , , xyz1, rgb
+PIPE_FORMAT_R16G16B16A16_FLOAT , plain, 1, 1, f16 , f16 , f16 , f16 , xyzw, rgb
+PIPE_FORMAT_R16_UNORM , plain, 1, 1, un16, , , , x001, rgb
+PIPE_FORMAT_R16G16_UNORM , plain, 1, 1, un16, un16, , , xy01, rgb
+PIPE_FORMAT_R16G16B16_UNORM , plain, 1, 1, un16, un16, un16, , xyz1, rgb
+PIPE_FORMAT_R16G16B16A16_UNORM , plain, 1, 1, un16, un16, un16, un16, xyzw, rgb
+PIPE_FORMAT_R16_USCALED , plain, 1, 1, u16 , , , , x001, rgb
+PIPE_FORMAT_R16G16_USCALED , plain, 1, 1, u16 , u16 , , , xy01, rgb
+PIPE_FORMAT_R16G16B16_USCALED , plain, 1, 1, u16 , u16 , u16 , , xyz1, rgb
+PIPE_FORMAT_R16G16B16A16_USCALED , plain, 1, 1, u16 , u16 , u16 , u16 , xyzw, rgb
+PIPE_FORMAT_R16_SNORM , plain, 1, 1, sn16, , , , x001, rgb
+PIPE_FORMAT_R16G16_SNORM , plain, 1, 1, sn16, sn16, , , xy01, rgb
+PIPE_FORMAT_R16G16B16_SNORM , plain, 1, 1, sn16, sn16, sn16, , xyz1, rgb
+PIPE_FORMAT_R16G16B16A16_SNORM , plain, 1, 1, sn16, sn16, sn16, sn16, xyzw, rgb
+PIPE_FORMAT_R16_SSCALED , plain, 1, 1, s16 , , , , x001, rgb
+PIPE_FORMAT_R16G16_SSCALED , plain, 1, 1, s16 , s16 , , , xy01, rgb
+PIPE_FORMAT_R16G16B16_SSCALED , plain, 1, 1, s16 , s16 , s16 , , xyz1, rgb
+PIPE_FORMAT_R16G16B16A16_SSCALED , plain, 1, 1, s16 , s16 , s16 , s16 , xyzw, rgb
+PIPE_FORMAT_R8_UNORM , plain, 1, 1, un8 , , , , x001, rgb
+PIPE_FORMAT_R8G8_UNORM , plain, 1, 1, un8 , un8 , , , xy01, rgb
+PIPE_FORMAT_R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , , xyz1, rgb
+PIPE_FORMAT_R8G8B8A8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , xyzw, rgb
+PIPE_FORMAT_R8_USCALED , plain, 1, 1, u8 , , , , x001, rgb
+PIPE_FORMAT_R8G8_USCALED , plain, 1, 1, u8 , u8 , , , xy01, rgb
+PIPE_FORMAT_R8G8B8_USCALED , plain, 1, 1, u8 , u8 , u8 , , xyz1, rgb
+PIPE_FORMAT_R8G8B8A8_USCALED , plain, 1, 1, u8 , u8 , u8 , u8 , xyzw, rgb
+PIPE_FORMAT_R8_SNORM , plain, 1, 1, sn8 , , , , x001, rgb
+PIPE_FORMAT_R8G8_SNORM , plain, 1, 1, sn8 , sn8 , , , xy01, rgb
+PIPE_FORMAT_R8G8B8_SNORM , plain, 1, 1, sn8 , sn8 , sn8 , , xyz1, rgb
+PIPE_FORMAT_R8G8B8A8_SNORM , plain, 1, 1, sn8 , sn8 , sn8 , sn8 , xyzw, rgb
+PIPE_FORMAT_R8_SSCALED , plain, 1, 1, s8 , , , , x001, rgb
+PIPE_FORMAT_R8G8_SSCALED , plain, 1, 1, s8 , s8 , , , xy01, rgb
+PIPE_FORMAT_R8G8B8_SSCALED , plain, 1, 1, s8 , s8 , s8 , , xyz1, rgb
+PIPE_FORMAT_R8G8B8A8_SSCALED , plain, 1, 1, s8 , s8 , s8 , s8 , xyzw, rgb
+
+# GL-specific vertex buffer element formats
+# A.k.a. GL_FIXED
+PIPE_FORMAT_R32_FIXED , plain, 1, 1, h32 , , , , x001, rgb
+PIPE_FORMAT_R32G32_FIXED , plain, 1, 1, h32 , h32 , , , xy01, rgb
+PIPE_FORMAT_R32G32B32_FIXED , plain, 1, 1, h32 , h32 , h32 , , xyz1, rgb
+PIPE_FORMAT_R32G32B32A32_FIXED , plain, 1, 1, h32 , h32 , h32 , h32 , xyzw, rgb
+
+# D3D9-specific vertex buffer element formats
+# See also:
+# - http://msdn.microsoft.com/en-us/library/bb172533.aspx
+# A.k.a. D3DDECLTYPE_UDEC3
+PIPE_FORMAT_R10G10B10X2_USCALED , plain, 1, 1, u10 , u10 , u10 , x2 , xyz1, rgb
+# A.k.a. D3DDECLTYPE_DEC3N
+PIPE_FORMAT_R10G10B10X2_SNORM , plain, 1, 1, sn10, sn10, sn10 , x2 , xyz1, rgb
+
+PIPE_FORMAT_YV12 , subsampled, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv
+PIPE_FORMAT_YV16 , subsampled, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv
+PIPE_FORMAT_IYUV , subsampled, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv
+PIPE_FORMAT_NV12 , subsampled, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv
+PIPE_FORMAT_NV21 , subsampled, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv
+PIPE_FORMAT_IA44 , subsampled, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv
+PIPE_FORMAT_AI44 , subsampled, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv
diff --git a/mesalib/src/gallium/auxiliary/util/u_format_yuv.c b/mesalib/src/gallium/auxiliary/util/u_format_yuv.c
index d1852af2d..64ea0b353 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format_yuv.c
+++ b/mesalib/src/gallium/auxiliary/util/u_format_yuv.c
@@ -1,1047 +1,1182 @@
-/**************************************************************************
- *
- * Copyright 2010 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- **************************************************************************/
-
-
-/**
- * @file
- * YUV and RGB subsampled formats conversion.
- *
- * @author Jose Fonseca <jfonseca@vmware.com>
- */
-
-
-#include "util/u_format_yuv.h"
-
-
-void
-util_format_r8g8_b8g8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
-
- for (y = 0; y < height; y += 1) {
- float *dst = dst_row;
- const uint32_t *src = (const uint32_t *)src_row;
- uint32_t value;
- float r, g0, g1, b;
-
- for (x = 0; x + 1 < width; x += 2) {
- value = *src++;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- r = ubyte_to_float((value >> 0) & 0xff);
- g0 = ubyte_to_float((value >> 8) & 0xff);
- b = ubyte_to_float((value >> 16) & 0xff);
- g1 = ubyte_to_float((value >> 24) & 0xff);
-
- dst[0] = r; /* r */
- dst[1] = g0; /* g */
- dst[2] = b; /* b */
- dst[3] = 1.0f; /* a */
- dst += 4;
-
- dst[0] = r; /* r */
- dst[1] = g1; /* g */
- dst[2] = b; /* b */
- dst[3] = 1.0f; /* a */
- dst += 4;
- }
-
- if (x < width) {
- value = *src;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- r = ubyte_to_float((value >> 0) & 0xff);
- g0 = ubyte_to_float((value >> 8) & 0xff);
- b = ubyte_to_float((value >> 16) & 0xff);
- g1 = ubyte_to_float((value >> 24) & 0xff);
-
- dst[0] = r; /* r */
- dst[1] = g0; /* g */
- dst[2] = b; /* b */
- dst[3] = 1.0f; /* a */
- }
-
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-
-void
-util_format_r8g8_b8g8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
-
- for (y = 0; y < height; y += 1) {
- uint8_t *dst = dst_row;
- const uint32_t *src = (const uint32_t *)src_row;
- uint32_t value;
- uint8_t r, g0, g1, b;
-
- for (x = 0; x + 1 < width; x += 2) {
- value = *src++;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- r = (value >> 0) & 0xff;
- g0 = (value >> 8) & 0xff;
- b = (value >> 16) & 0xff;
- g1 = (value >> 24) & 0xff;
-
- dst[0] = r; /* r */
- dst[1] = g0; /* g */
- dst[2] = b; /* b */
- dst[3] = 0xff; /* a */
- dst += 4;
-
- dst[0] = r; /* r */
- dst[1] = g1; /* g */
- dst[2] = b; /* b */
- dst[3] = 0xff; /* a */
- dst += 4;
- }
-
- if (x < width) {
- value = *src;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- r = (value >> 0) & 0xff;
- g0 = (value >> 8) & 0xff;
- b = (value >> 16) & 0xff;
- g1 = (value >> 24) & 0xff;
-
- dst[0] = r; /* r */
- dst[1] = g0; /* g */
- dst[2] = b; /* b */
- dst[3] = 0xff; /* a */
- }
-
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-
-void
-util_format_r8g8_b8g8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
- const float *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
-
- for (y = 0; y < height; y += 1) {
- const float *src = src_row;
- uint32_t *dst = (uint32_t *)dst_row;
- float r, g0, g1, b;
- uint32_t value;
-
- for (x = 0; x + 1 < width; x += 2) {
- r = 0.5f*(src[0] + src[4]);
- g0 = src[1];
- g1 = src[5];
- b = 0.5f*(src[2] + src[6]);
-
- value = float_to_ubyte(r);
- value |= float_to_ubyte(g0) << 8;
- value |= float_to_ubyte(b) << 16;
- value |= float_to_ubyte(g1) << 24;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst++ = value;
-
- src += 8;
- }
-
- if (x < width) {
- r = src[0];
- g0 = src[1];
- g1 = 0;
- b = src[2];
-
- value = float_to_ubyte(r);
- value |= float_to_ubyte(g0) << 8;
- value |= float_to_ubyte(b) << 16;
- value |= float_to_ubyte(g1) << 24;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst = value;
- }
-
- dst_row += dst_stride/sizeof(*dst_row);
- src_row += src_stride/sizeof(*src_row);
- }
-}
-
-
-void
-util_format_r8g8_b8g8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
-
- for (y = 0; y < height; y += 1) {
- const uint8_t *src = src_row;
- uint32_t *dst = (uint32_t *)dst_row;
- uint32_t r, g0, g1, b;
- uint32_t value;
-
- for (x = 0; x + 1 < width; x += 2) {
- r = (src[0] + src[4] + 1) >> 1;
- g0 = src[1];
- g1 = src[5];
- b = (src[2] + src[6] + 1) >> 1;
-
- value = r;
- value |= g0 << 8;
- value |= b << 16;
- value |= g1 << 24;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst++ = value;
-
- src += 8;
- }
-
- if (x < width) {
- r = src[0];
- g0 = src[1];
- g1 = 0;
- b = src[2];
-
- value = r;
- value |= g0 << 8;
- value |= b << 16;
- value |= g1 << 24;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst = value;
- }
-
- dst_row += dst_stride/sizeof(*dst_row);
- src_row += src_stride/sizeof(*src_row);
- }
-}
-
-
-void
-util_format_r8g8_b8g8_unorm_fetch_rgba_float(float *dst, const uint8_t *src,
- unsigned i, unsigned j)
-{
- assert(i < 2);
- assert(j < 1);
-
- dst[0] = ubyte_to_float(src[0]); /* r */
- dst[1] = ubyte_to_float(src[1 + 2*i]); /* g */
- dst[2] = ubyte_to_float(src[2]); /* b */
- dst[3] = 1.0f; /* a */
-}
-
-
-void
-util_format_g8r8_g8b8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
-
- for (y = 0; y < height; y += 1) {
- float *dst = dst_row;
- const uint32_t *src = (const uint32_t *)src_row;
- uint32_t value;
- float r, g0, g1, b;
-
- for (x = 0; x + 1 < width; x += 2) {
- value = *src++;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- g0 = ubyte_to_float((value >> 0) & 0xff);
- r = ubyte_to_float((value >> 8) & 0xff);
- g1 = ubyte_to_float((value >> 16) & 0xff);
- b = ubyte_to_float((value >> 24) & 0xff);
-
- dst[0] = r; /* r */
- dst[1] = g0; /* g */
- dst[2] = b; /* b */
- dst[3] = 1.0f; /* a */
- dst += 4;
-
- dst[0] = r; /* r */
- dst[1] = g1; /* g */
- dst[2] = b; /* b */
- dst[3] = 1.0f; /* a */
- dst += 4;
- }
-
- if (x < width) {
- value = *src;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- g0 = ubyte_to_float((value >> 0) & 0xff);
- r = ubyte_to_float((value >> 8) & 0xff);
- g1 = ubyte_to_float((value >> 16) & 0xff);
- b = ubyte_to_float((value >> 24) & 0xff);
-
- dst[0] = r; /* r */
- dst[1] = g0; /* g */
- dst[2] = b; /* b */
- dst[3] = 1.0f; /* a */
- }
-
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-
-void
-util_format_g8r8_g8b8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
-
- for (y = 0; y < height; y += 1) {
- uint8_t *dst = dst_row;
- const uint32_t *src = (const uint32_t *)src_row;
- uint32_t value;
- uint8_t r, g0, g1, b;
-
- for (x = 0; x + 1 < width; x += 2) {
- value = *src++;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- g0 = (value >> 0) & 0xff;
- r = (value >> 8) & 0xff;
- g1 = (value >> 16) & 0xff;
- b = (value >> 24) & 0xff;
-
- dst[0] = r; /* r */
- dst[1] = g0; /* g */
- dst[2] = b; /* b */
- dst[3] = 0xff; /* a */
- dst += 4;
-
- dst[0] = r; /* r */
- dst[1] = g1; /* g */
- dst[2] = b; /* b */
- dst[3] = 0xff; /* a */
- dst += 4;
- }
-
- if (x < width) {
- value = *src;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- g0 = (value >> 0) & 0xff;
- r = (value >> 8) & 0xff;
- g1 = (value >> 16) & 0xff;
- b = (value >> 24) & 0xff;
-
- dst[0] = r; /* r */
- dst[1] = g0; /* g */
- dst[2] = b; /* b */
- dst[3] = 0xff; /* a */
- }
-
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-
-void
-util_format_g8r8_g8b8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
- const float *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
-
- for (y = 0; y < height; y += 1) {
- const float *src = src_row;
- uint32_t *dst = (uint32_t *)dst_row;
- float r, g0, g1, b;
- uint32_t value;
-
- for (x = 0; x + 1 < width; x += 2) {
- r = 0.5f*(src[0] + src[4]);
- g0 = src[1];
- g1 = src[5];
- b = 0.5f*(src[2] + src[6]);
-
- value = float_to_ubyte(g0);
- value |= float_to_ubyte(r) << 8;
- value |= float_to_ubyte(g1) << 16;
- value |= float_to_ubyte(b) << 24;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst++ = value;
-
- src += 8;
- }
-
- if (x < width) {
- r = src[0];
- g0 = src[1];
- g1 = 0;
- b = src[2];
-
- value = float_to_ubyte(g0);
- value |= float_to_ubyte(r) << 8;
- value |= float_to_ubyte(g1) << 16;
- value |= float_to_ubyte(b) << 24;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst = value;
- }
-
- dst_row += dst_stride/sizeof(*dst_row);
- src_row += src_stride/sizeof(*src_row);
- }
-}
-
-
-void
-util_format_g8r8_g8b8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
-
- for (y = 0; y < height; y += 1) {
- const uint8_t *src = src_row;
- uint32_t *dst = (uint32_t *)dst_row;
- uint32_t r, g0, g1, b;
- uint32_t value;
-
- for (x = 0; x + 1 < width; x += 2) {
- r = (src[0] + src[4] + 1) >> 1;
- g0 = src[1];
- g1 = src[5];
- b = (src[2] + src[6] + 1) >> 1;
-
- value = g0;
- value |= r << 8;
- value |= g1 << 16;
- value |= b << 24;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst++ = value;
-
- src += 8;
- }
-
- if (x < width) {
- r = src[0];
- g0 = src[1];
- g1 = 0;
- b = src[2];
-
- value = g0;
- value |= r << 8;
- value |= g1 << 16;
- value |= b << 24;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst = value;
- }
-
- dst_row += dst_stride/sizeof(*dst_row);
- src_row += src_stride/sizeof(*src_row);
- }
-}
-
-
-void
-util_format_g8r8_g8b8_unorm_fetch_rgba_float(float *dst, const uint8_t *src,
- unsigned i, unsigned j)
-{
- assert(i < 2);
- assert(j < 1);
-
- dst[0] = ubyte_to_float(src[1]); /* r */
- dst[1] = ubyte_to_float(src[0 + 2*i]); /* g */
- dst[2] = ubyte_to_float(src[3]); /* b */
- dst[3] = 1.0f; /* a */
-}
-
-
-void
-util_format_uyvy_unpack_rgba_float(float *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
-
- for (y = 0; y < height; y += 1) {
- float *dst = dst_row;
- const uint32_t *src = (const uint32_t *)src_row;
- uint32_t value;
- uint8_t y0, y1, u, v;
-
- for (x = 0; x + 1 < width; x += 2) {
- value = *src++;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- u = (value >> 0) & 0xff;
- y0 = (value >> 8) & 0xff;
- v = (value >> 16) & 0xff;
- y1 = (value >> 24) & 0xff;
-
- util_format_yuv_to_rgb_float(y0, u, v, &dst[0], &dst[1], &dst[2]);
- dst[3] = 1.0f; /* a */
- dst += 4;
-
- util_format_yuv_to_rgb_float(y1, u, v, &dst[0], &dst[1], &dst[2]);
- dst[3] = 1.0f; /* a */
- dst += 4;
- }
-
- if (x < width) {
- value = *src;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- u = (value >> 0) & 0xff;
- y0 = (value >> 8) & 0xff;
- v = (value >> 16) & 0xff;
- y1 = (value >> 24) & 0xff;
-
- util_format_yuv_to_rgb_float(y0, u, v, &dst[0], &dst[1], &dst[2]);
- dst[3] = 1.0f; /* a */
- }
-
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-
-void
-util_format_uyvy_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
-
- for (y = 0; y < height; y += 1) {
- uint8_t *dst = dst_row;
- const uint32_t *src = (const uint32_t *)src_row;
- uint32_t value;
- uint8_t y0, y1, u, v;
-
- for (x = 0; x + 1 < width; x += 2) {
- value = *src++;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- u = (value >> 0) & 0xff;
- y0 = (value >> 8) & 0xff;
- v = (value >> 16) & 0xff;
- y1 = (value >> 24) & 0xff;
-
- util_format_yuv_to_rgb_8unorm(y0, u, v, &dst[0], &dst[1], &dst[2]);
- dst[3] = 0xff; /* a */
- dst += 4;
-
- util_format_yuv_to_rgb_8unorm(y1, u, v, &dst[0], &dst[1], &dst[2]);
- dst[3] = 0xff; /* a */
- dst += 4;
- }
-
- if (x < width) {
- value = *src;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- u = (value >> 0) & 0xff;
- y0 = (value >> 8) & 0xff;
- v = (value >> 16) & 0xff;
- y1 = (value >> 24) & 0xff;
-
- util_format_yuv_to_rgb_8unorm(y0, u, v, &dst[0], &dst[1], &dst[2]);
- dst[3] = 0xff; /* a */
- }
-
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-
-void
-util_format_uyvy_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
- const float *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
-
- for (y = 0; y < height; y += 1) {
- const float *src = src_row;
- uint32_t *dst = (uint32_t *)dst_row;
- uint8_t y0, y1, u, v;
- uint32_t value;
-
- for (x = 0; x + 1 < width; x += 2) {
- uint8_t y0, y1, u0, u1, v0, v1, u, v;
-
- util_format_rgb_float_to_yuv(src[0], src[1], src[2],
- &y0, &u0, &v0);
- util_format_rgb_float_to_yuv(src[4], src[5], src[6],
- &y1, &u1, &v1);
-
- u = (u0 + u1 + 1) >> 1;
- v = (v0 + v1 + 1) >> 1;
-
- value = u;
- value |= y0 << 8;
- value |= v << 16;
- value |= y1 << 24;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst++ = value;
-
- src += 8;
- }
-
- if (x < width) {
- util_format_rgb_float_to_yuv(src[0], src[1], src[2],
- &y0, &u, &v);
- y1 = 0;
-
- value = u;
- value |= y0 << 8;
- value |= v << 16;
- value |= y1 << 24;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst = value;
- }
-
- dst_row += dst_stride/sizeof(*dst_row);
- src_row += src_stride/sizeof(*src_row);
- }
-}
-
-
-void
-util_format_uyvy_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
-
- for (y = 0; y < height; y += 1) {
- const uint8_t *src = src_row;
- uint32_t *dst = (uint32_t *)dst_row;
- uint8_t y0, y1, u, v;
- uint32_t value;
-
- for (x = 0; x + 1 < width; x += 2) {
- uint8_t y0, y1, u0, u1, v0, v1, u, v;
-
- util_format_rgb_8unorm_to_yuv(src[0], src[1], src[2],
- &y0, &u0, &v0);
- util_format_rgb_8unorm_to_yuv(src[4], src[5], src[6],
- &y1, &u1, &v1);
-
- u = (u0 + u1 + 1) >> 1;
- v = (v0 + v1 + 1) >> 1;
-
- value = u;
- value |= y0 << 8;
- value |= v << 16;
- value |= y1 << 24;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst++ = value;
-
- src += 8;
- }
-
- if (x < width) {
- util_format_rgb_8unorm_to_yuv(src[0], src[1], src[2],
- &y0, &u, &v);
- y1 = 0;
-
- value = u;
- value |= y0 << 8;
- value |= v << 16;
- value |= y1 << 24;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst = value;
- }
-
- dst_row += dst_stride/sizeof(*dst_row);
- src_row += src_stride/sizeof(*src_row);
- }
-}
-
-
-void
-util_format_uyvy_fetch_rgba_float(float *dst, const uint8_t *src,
- unsigned i, unsigned j)
-{
- uint8_t y, u, v;
-
- assert(i < 2);
- assert(j < 1);
-
- y = src[1 + i*2];
- u = src[0];
- v = src[2];
-
- util_format_yuv_to_rgb_float(y, u, v, &dst[0], &dst[1], &dst[2]);
-
- dst[3] = 1.0f;
-}
-
-
-void
-util_format_yuyv_unpack_rgba_float(float *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
-
- for (y = 0; y < height; y += 1) {
- float *dst = dst_row;
- const uint32_t *src = (const uint32_t *)src_row;
- uint32_t value;
- uint8_t y0, y1, u, v;
-
- for (x = 0; x + 1 < width; x += 2) {
- value = *src++;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- y0 = (value >> 0) & 0xff;
- u = (value >> 8) & 0xff;
- y1 = (value >> 16) & 0xff;
- v = (value >> 24) & 0xff;
-
- util_format_yuv_to_rgb_float(y0, u, v, &dst[0], &dst[1], &dst[2]);
- dst[3] = 1.0f; /* a */
- dst += 4;
-
- util_format_yuv_to_rgb_float(y1, u, v, &dst[0], &dst[1], &dst[2]);
- dst[3] = 1.0f; /* a */
- dst += 4;
- }
-
- if (x < width) {
- value = *src;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- y0 = (value >> 0) & 0xff;
- u = (value >> 8) & 0xff;
- y1 = (value >> 16) & 0xff;
- v = (value >> 24) & 0xff;
-
- util_format_yuv_to_rgb_float(y0, u, v, &dst[0], &dst[1], &dst[2]);
- dst[3] = 1.0f; /* a */
- }
-
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-
-void
-util_format_yuyv_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
-
- for (y = 0; y < height; y += 1) {
- uint8_t *dst = dst_row;
- const uint32_t *src = (const uint32_t *)src_row;
- uint32_t value;
- uint8_t y0, y1, u, v;
-
- for (x = 0; x + 1 < width; x += 2) {
- value = *src++;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- y0 = (value >> 0) & 0xff;
- u = (value >> 8) & 0xff;
- y1 = (value >> 16) & 0xff;
- v = (value >> 24) & 0xff;
-
- util_format_yuv_to_rgb_8unorm(y0, u, v, &dst[0], &dst[1], &dst[2]);
- dst[3] = 0xff; /* a */
- dst += 4;
-
- util_format_yuv_to_rgb_8unorm(y1, u, v, &dst[0], &dst[1], &dst[2]);
- dst[3] = 0xff; /* a */
- dst += 4;
- }
-
- if (x < width) {
- value = *src;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- y0 = (value >> 0) & 0xff;
- u = (value >> 8) & 0xff;
- y1 = (value >> 16) & 0xff;
- v = (value >> 24) & 0xff;
-
- util_format_yuv_to_rgb_8unorm(y0, u, v, &dst[0], &dst[1], &dst[2]);
- dst[3] = 0xff; /* a */
- }
-
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-
-void
-util_format_yuyv_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
- const float *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
-
- for (y = 0; y < height; y += 1) {
- const float *src = src_row;
- uint32_t *dst = (uint32_t *)dst_row;
- uint8_t y0, y1, u, v;
- uint32_t value;
-
- for (x = 0; x + 1 < width; x += 2) {
- uint8_t y0, y1, u0, u1, v0, v1, u, v;
-
- util_format_rgb_float_to_yuv(src[0], src[1], src[2],
- &y0, &u0, &v0);
- util_format_rgb_float_to_yuv(src[4], src[5], src[6],
- &y1, &u1, &v1);
-
- u = (u0 + u1 + 1) >> 1;
- v = (v0 + v1 + 1) >> 1;
-
- value = y0;
- value |= u << 8;
- value |= y1 << 16;
- value |= v << 24;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst++ = value;
-
- src += 8;
- }
-
- if (x < width) {
- util_format_rgb_float_to_yuv(src[0], src[1], src[2],
- &y0, &u, &v);
- y1 = 0;
-
- value = y0;
- value |= u << 8;
- value |= y1 << 16;
- value |= v << 24;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst = value;
- }
-
- dst_row += dst_stride/sizeof(*dst_row);
- src_row += src_stride/sizeof(*src_row);
- }
-}
-
-
-void
-util_format_yuyv_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
-
- for (y = 0; y < height; y += 1) {
- const uint8_t *src = src_row;
- uint32_t *dst = (uint32_t *)dst_row;
- uint8_t y0, y1, u, v;
- uint32_t value;
-
- for (x = 0; x + 1 < width; x += 2) {
- uint8_t y0, y1, u0, u1, v0, v1, u, v;
-
- util_format_rgb_8unorm_to_yuv(src[0], src[1], src[2],
- &y0, &u0, &v0);
- util_format_rgb_8unorm_to_yuv(src[4], src[5], src[6],
- &y1, &u1, &v1);
-
- u = (u0 + u1 + 1) >> 1;
- v = (v0 + v1 + 1) >> 1;
-
- value = y0;
- value |= u << 8;
- value |= y1 << 16;
- value |= v << 24;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst++ = value;
-
- src += 8;
- }
-
- if (x < width) {
- util_format_rgb_8unorm_to_yuv(src[0], src[1], src[2],
- &y0, &u, &v);
- y1 = 0;
-
- value = y0;
- value |= u << 8;
- value |= y1 << 16;
- value |= v << 24;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst = value;
- }
-
- dst_row += dst_stride/sizeof(*dst_row);
- src_row += src_stride/sizeof(*src_row);
- }
-}
-
-
-void
-util_format_yuyv_fetch_rgba_float(float *dst, const uint8_t *src,
- unsigned i, unsigned j)
-{
- uint8_t y, u, v;
-
- assert(i < 2);
- assert(j < 1);
-
- y = src[0 + i*2];
- u = src[1];
- v = src[3];
-
- util_format_yuv_to_rgb_float(y, u, v, &dst[0], &dst[1], &dst[2]);
-
- dst[3] = 1.0f;
-}
+/**************************************************************************
+ *
+ * Copyright 2010 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ **************************************************************************/
+
+
+/**
+ * @file
+ * YUV and RGB subsampled formats conversion.
+ *
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ */
+
+
+#include "util/u_format_yuv.h"
+
+
+void
+util_format_r8g8_b8g8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+
+ for (y = 0; y < height; y += 1) {
+ float *dst = dst_row;
+ const uint32_t *src = (const uint32_t *)src_row;
+ uint32_t value;
+ float r, g0, g1, b;
+
+ for (x = 0; x + 1 < width; x += 2) {
+ value = *src++;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ r = ubyte_to_float((value >> 0) & 0xff);
+ g0 = ubyte_to_float((value >> 8) & 0xff);
+ b = ubyte_to_float((value >> 16) & 0xff);
+ g1 = ubyte_to_float((value >> 24) & 0xff);
+
+ dst[0] = r; /* r */
+ dst[1] = g0; /* g */
+ dst[2] = b; /* b */
+ dst[3] = 1.0f; /* a */
+ dst += 4;
+
+ dst[0] = r; /* r */
+ dst[1] = g1; /* g */
+ dst[2] = b; /* b */
+ dst[3] = 1.0f; /* a */
+ dst += 4;
+ }
+
+ if (x < width) {
+ value = *src;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ r = ubyte_to_float((value >> 0) & 0xff);
+ g0 = ubyte_to_float((value >> 8) & 0xff);
+ b = ubyte_to_float((value >> 16) & 0xff);
+ g1 = ubyte_to_float((value >> 24) & 0xff);
+
+ dst[0] = r; /* r */
+ dst[1] = g0; /* g */
+ dst[2] = b; /* b */
+ dst[3] = 1.0f; /* a */
+ }
+
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+
+void
+util_format_r8g8_b8g8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+
+ for (y = 0; y < height; y += 1) {
+ uint8_t *dst = dst_row;
+ const uint32_t *src = (const uint32_t *)src_row;
+ uint32_t value;
+ uint8_t r, g0, g1, b;
+
+ for (x = 0; x + 1 < width; x += 2) {
+ value = *src++;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ r = (value >> 0) & 0xff;
+ g0 = (value >> 8) & 0xff;
+ b = (value >> 16) & 0xff;
+ g1 = (value >> 24) & 0xff;
+
+ dst[0] = r; /* r */
+ dst[1] = g0; /* g */
+ dst[2] = b; /* b */
+ dst[3] = 0xff; /* a */
+ dst += 4;
+
+ dst[0] = r; /* r */
+ dst[1] = g1; /* g */
+ dst[2] = b; /* b */
+ dst[3] = 0xff; /* a */
+ dst += 4;
+ }
+
+ if (x < width) {
+ value = *src;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ r = (value >> 0) & 0xff;
+ g0 = (value >> 8) & 0xff;
+ b = (value >> 16) & 0xff;
+ g1 = (value >> 24) & 0xff;
+
+ dst[0] = r; /* r */
+ dst[1] = g0; /* g */
+ dst[2] = b; /* b */
+ dst[3] = 0xff; /* a */
+ }
+
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+
+void
+util_format_r8g8_b8g8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+
+ for (y = 0; y < height; y += 1) {
+ const float *src = src_row;
+ uint32_t *dst = (uint32_t *)dst_row;
+ float r, g0, g1, b;
+ uint32_t value;
+
+ for (x = 0; x + 1 < width; x += 2) {
+ r = 0.5f*(src[0] + src[4]);
+ g0 = src[1];
+ g1 = src[5];
+ b = 0.5f*(src[2] + src[6]);
+
+ value = float_to_ubyte(r);
+ value |= float_to_ubyte(g0) << 8;
+ value |= float_to_ubyte(b) << 16;
+ value |= float_to_ubyte(g1) << 24;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ *dst++ = value;
+
+ src += 8;
+ }
+
+ if (x < width) {
+ r = src[0];
+ g0 = src[1];
+ g1 = 0;
+ b = src[2];
+
+ value = float_to_ubyte(r);
+ value |= float_to_ubyte(g0) << 8;
+ value |= float_to_ubyte(b) << 16;
+ value |= float_to_ubyte(g1) << 24;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ *dst = value;
+ }
+
+ dst_row += dst_stride/sizeof(*dst_row);
+ src_row += src_stride/sizeof(*src_row);
+ }
+}
+
+
+void
+util_format_r8g8_b8g8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+
+ for (y = 0; y < height; y += 1) {
+ const uint8_t *src = src_row;
+ uint32_t *dst = (uint32_t *)dst_row;
+ uint32_t r, g0, g1, b;
+ uint32_t value;
+
+ for (x = 0; x + 1 < width; x += 2) {
+ r = (src[0] + src[4] + 1) >> 1;
+ g0 = src[1];
+ g1 = src[5];
+ b = (src[2] + src[6] + 1) >> 1;
+
+ value = r;
+ value |= g0 << 8;
+ value |= b << 16;
+ value |= g1 << 24;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ *dst++ = value;
+
+ src += 8;
+ }
+
+ if (x < width) {
+ r = src[0];
+ g0 = src[1];
+ g1 = 0;
+ b = src[2];
+
+ value = r;
+ value |= g0 << 8;
+ value |= b << 16;
+ value |= g1 << 24;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ *dst = value;
+ }
+
+ dst_row += dst_stride/sizeof(*dst_row);
+ src_row += src_stride/sizeof(*src_row);
+ }
+}
+
+
+void
+util_format_r8g8_b8g8_unorm_fetch_rgba_float(float *dst, const uint8_t *src,
+ unsigned i, unsigned j)
+{
+ assert(i < 2);
+ assert(j < 1);
+
+ dst[0] = ubyte_to_float(src[0]); /* r */
+ dst[1] = ubyte_to_float(src[1 + 2*i]); /* g */
+ dst[2] = ubyte_to_float(src[2]); /* b */
+ dst[3] = 1.0f; /* a */
+}
+
+
+void
+util_format_g8r8_g8b8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+
+ for (y = 0; y < height; y += 1) {
+ float *dst = dst_row;
+ const uint32_t *src = (const uint32_t *)src_row;
+ uint32_t value;
+ float r, g0, g1, b;
+
+ for (x = 0; x + 1 < width; x += 2) {
+ value = *src++;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ g0 = ubyte_to_float((value >> 0) & 0xff);
+ r = ubyte_to_float((value >> 8) & 0xff);
+ g1 = ubyte_to_float((value >> 16) & 0xff);
+ b = ubyte_to_float((value >> 24) & 0xff);
+
+ dst[0] = r; /* r */
+ dst[1] = g0; /* g */
+ dst[2] = b; /* b */
+ dst[3] = 1.0f; /* a */
+ dst += 4;
+
+ dst[0] = r; /* r */
+ dst[1] = g1; /* g */
+ dst[2] = b; /* b */
+ dst[3] = 1.0f; /* a */
+ dst += 4;
+ }
+
+ if (x < width) {
+ value = *src;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ g0 = ubyte_to_float((value >> 0) & 0xff);
+ r = ubyte_to_float((value >> 8) & 0xff);
+ g1 = ubyte_to_float((value >> 16) & 0xff);
+ b = ubyte_to_float((value >> 24) & 0xff);
+
+ dst[0] = r; /* r */
+ dst[1] = g0; /* g */
+ dst[2] = b; /* b */
+ dst[3] = 1.0f; /* a */
+ }
+
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+
+void
+util_format_g8r8_g8b8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+
+ for (y = 0; y < height; y += 1) {
+ uint8_t *dst = dst_row;
+ const uint32_t *src = (const uint32_t *)src_row;
+ uint32_t value;
+ uint8_t r, g0, g1, b;
+
+ for (x = 0; x + 1 < width; x += 2) {
+ value = *src++;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ g0 = (value >> 0) & 0xff;
+ r = (value >> 8) & 0xff;
+ g1 = (value >> 16) & 0xff;
+ b = (value >> 24) & 0xff;
+
+ dst[0] = r; /* r */
+ dst[1] = g0; /* g */
+ dst[2] = b; /* b */
+ dst[3] = 0xff; /* a */
+ dst += 4;
+
+ dst[0] = r; /* r */
+ dst[1] = g1; /* g */
+ dst[2] = b; /* b */
+ dst[3] = 0xff; /* a */
+ dst += 4;
+ }
+
+ if (x < width) {
+ value = *src;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ g0 = (value >> 0) & 0xff;
+ r = (value >> 8) & 0xff;
+ g1 = (value >> 16) & 0xff;
+ b = (value >> 24) & 0xff;
+
+ dst[0] = r; /* r */
+ dst[1] = g0; /* g */
+ dst[2] = b; /* b */
+ dst[3] = 0xff; /* a */
+ }
+
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+
+void
+util_format_g8r8_g8b8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+
+ for (y = 0; y < height; y += 1) {
+ const float *src = src_row;
+ uint32_t *dst = (uint32_t *)dst_row;
+ float r, g0, g1, b;
+ uint32_t value;
+
+ for (x = 0; x + 1 < width; x += 2) {
+ r = 0.5f*(src[0] + src[4]);
+ g0 = src[1];
+ g1 = src[5];
+ b = 0.5f*(src[2] + src[6]);
+
+ value = float_to_ubyte(g0);
+ value |= float_to_ubyte(r) << 8;
+ value |= float_to_ubyte(g1) << 16;
+ value |= float_to_ubyte(b) << 24;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ *dst++ = value;
+
+ src += 8;
+ }
+
+ if (x < width) {
+ r = src[0];
+ g0 = src[1];
+ g1 = 0;
+ b = src[2];
+
+ value = float_to_ubyte(g0);
+ value |= float_to_ubyte(r) << 8;
+ value |= float_to_ubyte(g1) << 16;
+ value |= float_to_ubyte(b) << 24;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ *dst = value;
+ }
+
+ dst_row += dst_stride/sizeof(*dst_row);
+ src_row += src_stride/sizeof(*src_row);
+ }
+}
+
+
+void
+util_format_g8r8_g8b8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+
+ for (y = 0; y < height; y += 1) {
+ const uint8_t *src = src_row;
+ uint32_t *dst = (uint32_t *)dst_row;
+ uint32_t r, g0, g1, b;
+ uint32_t value;
+
+ for (x = 0; x + 1 < width; x += 2) {
+ r = (src[0] + src[4] + 1) >> 1;
+ g0 = src[1];
+ g1 = src[5];
+ b = (src[2] + src[6] + 1) >> 1;
+
+ value = g0;
+ value |= r << 8;
+ value |= g1 << 16;
+ value |= b << 24;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ *dst++ = value;
+
+ src += 8;
+ }
+
+ if (x < width) {
+ r = src[0];
+ g0 = src[1];
+ g1 = 0;
+ b = src[2];
+
+ value = g0;
+ value |= r << 8;
+ value |= g1 << 16;
+ value |= b << 24;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ *dst = value;
+ }
+
+ dst_row += dst_stride/sizeof(*dst_row);
+ src_row += src_stride/sizeof(*src_row);
+ }
+}
+
+
+void
+util_format_g8r8_g8b8_unorm_fetch_rgba_float(float *dst, const uint8_t *src,
+ unsigned i, unsigned j)
+{
+ assert(i < 2);
+ assert(j < 1);
+
+ dst[0] = ubyte_to_float(src[1]); /* r */
+ dst[1] = ubyte_to_float(src[0 + 2*i]); /* g */
+ dst[2] = ubyte_to_float(src[3]); /* b */
+ dst[3] = 1.0f; /* a */
+}
+
+
+void
+util_format_uyvy_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+
+ for (y = 0; y < height; y += 1) {
+ float *dst = dst_row;
+ const uint32_t *src = (const uint32_t *)src_row;
+ uint32_t value;
+ uint8_t y0, y1, u, v;
+
+ for (x = 0; x + 1 < width; x += 2) {
+ value = *src++;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ u = (value >> 0) & 0xff;
+ y0 = (value >> 8) & 0xff;
+ v = (value >> 16) & 0xff;
+ y1 = (value >> 24) & 0xff;
+
+ util_format_yuv_to_rgb_float(y0, u, v, &dst[0], &dst[1], &dst[2]);
+ dst[3] = 1.0f; /* a */
+ dst += 4;
+
+ util_format_yuv_to_rgb_float(y1, u, v, &dst[0], &dst[1], &dst[2]);
+ dst[3] = 1.0f; /* a */
+ dst += 4;
+ }
+
+ if (x < width) {
+ value = *src;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ u = (value >> 0) & 0xff;
+ y0 = (value >> 8) & 0xff;
+ v = (value >> 16) & 0xff;
+ y1 = (value >> 24) & 0xff;
+
+ util_format_yuv_to_rgb_float(y0, u, v, &dst[0], &dst[1], &dst[2]);
+ dst[3] = 1.0f; /* a */
+ }
+
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+
+void
+util_format_uyvy_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+
+ for (y = 0; y < height; y += 1) {
+ uint8_t *dst = dst_row;
+ const uint32_t *src = (const uint32_t *)src_row;
+ uint32_t value;
+ uint8_t y0, y1, u, v;
+
+ for (x = 0; x + 1 < width; x += 2) {
+ value = *src++;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ u = (value >> 0) & 0xff;
+ y0 = (value >> 8) & 0xff;
+ v = (value >> 16) & 0xff;
+ y1 = (value >> 24) & 0xff;
+
+ util_format_yuv_to_rgb_8unorm(y0, u, v, &dst[0], &dst[1], &dst[2]);
+ dst[3] = 0xff; /* a */
+ dst += 4;
+
+ util_format_yuv_to_rgb_8unorm(y1, u, v, &dst[0], &dst[1], &dst[2]);
+ dst[3] = 0xff; /* a */
+ dst += 4;
+ }
+
+ if (x < width) {
+ value = *src;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ u = (value >> 0) & 0xff;
+ y0 = (value >> 8) & 0xff;
+ v = (value >> 16) & 0xff;
+ y1 = (value >> 24) & 0xff;
+
+ util_format_yuv_to_rgb_8unorm(y0, u, v, &dst[0], &dst[1], &dst[2]);
+ dst[3] = 0xff; /* a */
+ }
+
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+
+void
+util_format_uyvy_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+
+ for (y = 0; y < height; y += 1) {
+ const float *src = src_row;
+ uint32_t *dst = (uint32_t *)dst_row;
+ uint8_t y0, y1, u, v;
+ uint32_t value;
+
+ for (x = 0; x + 1 < width; x += 2) {
+ uint8_t y0, y1, u0, u1, v0, v1, u, v;
+
+ util_format_rgb_float_to_yuv(src[0], src[1], src[2],
+ &y0, &u0, &v0);
+ util_format_rgb_float_to_yuv(src[4], src[5], src[6],
+ &y1, &u1, &v1);
+
+ u = (u0 + u1 + 1) >> 1;
+ v = (v0 + v1 + 1) >> 1;
+
+ value = u;
+ value |= y0 << 8;
+ value |= v << 16;
+ value |= y1 << 24;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ *dst++ = value;
+
+ src += 8;
+ }
+
+ if (x < width) {
+ util_format_rgb_float_to_yuv(src[0], src[1], src[2],
+ &y0, &u, &v);
+ y1 = 0;
+
+ value = u;
+ value |= y0 << 8;
+ value |= v << 16;
+ value |= y1 << 24;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ *dst = value;
+ }
+
+ dst_row += dst_stride/sizeof(*dst_row);
+ src_row += src_stride/sizeof(*src_row);
+ }
+}
+
+
+void
+util_format_uyvy_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+
+ for (y = 0; y < height; y += 1) {
+ const uint8_t *src = src_row;
+ uint32_t *dst = (uint32_t *)dst_row;
+ uint8_t y0, y1, u, v;
+ uint32_t value;
+
+ for (x = 0; x + 1 < width; x += 2) {
+ uint8_t y0, y1, u0, u1, v0, v1, u, v;
+
+ util_format_rgb_8unorm_to_yuv(src[0], src[1], src[2],
+ &y0, &u0, &v0);
+ util_format_rgb_8unorm_to_yuv(src[4], src[5], src[6],
+ &y1, &u1, &v1);
+
+ u = (u0 + u1 + 1) >> 1;
+ v = (v0 + v1 + 1) >> 1;
+
+ value = u;
+ value |= y0 << 8;
+ value |= v << 16;
+ value |= y1 << 24;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ *dst++ = value;
+
+ src += 8;
+ }
+
+ if (x < width) {
+ util_format_rgb_8unorm_to_yuv(src[0], src[1], src[2],
+ &y0, &u, &v);
+ y1 = 0;
+
+ value = u;
+ value |= y0 << 8;
+ value |= v << 16;
+ value |= y1 << 24;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ *dst = value;
+ }
+
+ dst_row += dst_stride/sizeof(*dst_row);
+ src_row += src_stride/sizeof(*src_row);
+ }
+}
+
+
+void
+util_format_uyvy_fetch_rgba_float(float *dst, const uint8_t *src,
+ unsigned i, unsigned j)
+{
+ uint8_t y, u, v;
+
+ assert(i < 2);
+ assert(j < 1);
+
+ y = src[1 + i*2];
+ u = src[0];
+ v = src[2];
+
+ util_format_yuv_to_rgb_float(y, u, v, &dst[0], &dst[1], &dst[2]);
+
+ dst[3] = 1.0f;
+}
+
+
+void
+util_format_yuyv_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+
+ for (y = 0; y < height; y += 1) {
+ float *dst = dst_row;
+ const uint32_t *src = (const uint32_t *)src_row;
+ uint32_t value;
+ uint8_t y0, y1, u, v;
+
+ for (x = 0; x + 1 < width; x += 2) {
+ value = *src++;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ y0 = (value >> 0) & 0xff;
+ u = (value >> 8) & 0xff;
+ y1 = (value >> 16) & 0xff;
+ v = (value >> 24) & 0xff;
+
+ util_format_yuv_to_rgb_float(y0, u, v, &dst[0], &dst[1], &dst[2]);
+ dst[3] = 1.0f; /* a */
+ dst += 4;
+
+ util_format_yuv_to_rgb_float(y1, u, v, &dst[0], &dst[1], &dst[2]);
+ dst[3] = 1.0f; /* a */
+ dst += 4;
+ }
+
+ if (x < width) {
+ value = *src;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ y0 = (value >> 0) & 0xff;
+ u = (value >> 8) & 0xff;
+ y1 = (value >> 16) & 0xff;
+ v = (value >> 24) & 0xff;
+
+ util_format_yuv_to_rgb_float(y0, u, v, &dst[0], &dst[1], &dst[2]);
+ dst[3] = 1.0f; /* a */
+ }
+
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+
+void
+util_format_yuyv_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+
+ for (y = 0; y < height; y += 1) {
+ uint8_t *dst = dst_row;
+ const uint32_t *src = (const uint32_t *)src_row;
+ uint32_t value;
+ uint8_t y0, y1, u, v;
+
+ for (x = 0; x + 1 < width; x += 2) {
+ value = *src++;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ y0 = (value >> 0) & 0xff;
+ u = (value >> 8) & 0xff;
+ y1 = (value >> 16) & 0xff;
+ v = (value >> 24) & 0xff;
+
+ util_format_yuv_to_rgb_8unorm(y0, u, v, &dst[0], &dst[1], &dst[2]);
+ dst[3] = 0xff; /* a */
+ dst += 4;
+
+ util_format_yuv_to_rgb_8unorm(y1, u, v, &dst[0], &dst[1], &dst[2]);
+ dst[3] = 0xff; /* a */
+ dst += 4;
+ }
+
+ if (x < width) {
+ value = *src;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ y0 = (value >> 0) & 0xff;
+ u = (value >> 8) & 0xff;
+ y1 = (value >> 16) & 0xff;
+ v = (value >> 24) & 0xff;
+
+ util_format_yuv_to_rgb_8unorm(y0, u, v, &dst[0], &dst[1], &dst[2]);
+ dst[3] = 0xff; /* a */
+ }
+
+ src_row += src_stride/sizeof(*src_row);
+ dst_row += dst_stride/sizeof(*dst_row);
+ }
+}
+
+
+void
+util_format_yuyv_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+
+ for (y = 0; y < height; y += 1) {
+ const float *src = src_row;
+ uint32_t *dst = (uint32_t *)dst_row;
+ uint8_t y0, y1, u, v;
+ uint32_t value;
+
+ for (x = 0; x + 1 < width; x += 2) {
+ uint8_t y0, y1, u0, u1, v0, v1, u, v;
+
+ util_format_rgb_float_to_yuv(src[0], src[1], src[2],
+ &y0, &u0, &v0);
+ util_format_rgb_float_to_yuv(src[4], src[5], src[6],
+ &y1, &u1, &v1);
+
+ u = (u0 + u1 + 1) >> 1;
+ v = (v0 + v1 + 1) >> 1;
+
+ value = y0;
+ value |= u << 8;
+ value |= y1 << 16;
+ value |= v << 24;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ *dst++ = value;
+
+ src += 8;
+ }
+
+ if (x < width) {
+ util_format_rgb_float_to_yuv(src[0], src[1], src[2],
+ &y0, &u, &v);
+ y1 = 0;
+
+ value = y0;
+ value |= u << 8;
+ value |= y1 << 16;
+ value |= v << 24;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ *dst = value;
+ }
+
+ dst_row += dst_stride/sizeof(*dst_row);
+ src_row += src_stride/sizeof(*src_row);
+ }
+}
+
+
+void
+util_format_yuyv_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height)
+{
+ unsigned x, y;
+
+ for (y = 0; y < height; y += 1) {
+ const uint8_t *src = src_row;
+ uint32_t *dst = (uint32_t *)dst_row;
+ uint8_t y0, y1, u, v;
+ uint32_t value;
+
+ for (x = 0; x + 1 < width; x += 2) {
+ uint8_t y0, y1, u0, u1, v0, v1, u, v;
+
+ util_format_rgb_8unorm_to_yuv(src[0], src[1], src[2],
+ &y0, &u0, &v0);
+ util_format_rgb_8unorm_to_yuv(src[4], src[5], src[6],
+ &y1, &u1, &v1);
+
+ u = (u0 + u1 + 1) >> 1;
+ v = (v0 + v1 + 1) >> 1;
+
+ value = y0;
+ value |= u << 8;
+ value |= y1 << 16;
+ value |= v << 24;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ *dst++ = value;
+
+ src += 8;
+ }
+
+ if (x < width) {
+ util_format_rgb_8unorm_to_yuv(src[0], src[1], src[2],
+ &y0, &u, &v);
+ y1 = 0;
+
+ value = y0;
+ value |= u << 8;
+ value |= y1 << 16;
+ value |= v << 24;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ value = util_bswap32(value);
+#endif
+
+ *dst = value;
+ }
+
+ dst_row += dst_stride/sizeof(*dst_row);
+ src_row += src_stride/sizeof(*src_row);
+ }
+}
+
+
+void
+util_format_yuyv_fetch_rgba_float(float *dst, const uint8_t *src,
+ unsigned i, unsigned j)
+{
+ uint8_t y, u, v;
+
+ assert(i < 2);
+ assert(j < 1);
+
+ y = src[0 + i*2];
+ u = src[1];
+ v = src[3];
+
+ util_format_yuv_to_rgb_float(y, u, v, &dst[0], &dst[1], &dst[2]);
+
+ dst[3] = 1.0f;
+}
+
+/* XXX: Stubbed for now */
+void
+util_format_yv12_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_yv12_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_yv12_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_yv12_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_yv12_fetch_rgba_float(float *dst, const uint8_t *src,
+ unsigned i, unsigned j) {}
+void
+util_format_yv16_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_yv16_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_yv16_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_yv16_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_yv16_fetch_rgba_float(float *dst, const uint8_t *src,
+ unsigned i, unsigned j) {}
+void
+util_format_iyuv_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_iyuv_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_iyuv_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_iyuv_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_iyuv_fetch_rgba_float(float *dst, const uint8_t *src,
+ unsigned i, unsigned j) {}
+void
+util_format_nv12_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_nv12_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_nv12_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_nv12_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_nv12_fetch_rgba_float(float *dst, const uint8_t *src,
+ unsigned i, unsigned j) {}
+void
+util_format_nv21_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_nv21_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_nv21_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_nv21_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_nv21_fetch_rgba_float(float *dst, const uint8_t *src,
+ unsigned i, unsigned j) {}
+void
+util_format_ia44_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_ia44_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_ia44_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_ia44_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_ia44_fetch_rgba_float(float *dst, const uint8_t *src,
+ unsigned i, unsigned j) {}
+void
+util_format_ai44_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_ai44_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_ai44_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_ai44_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height) {}
+void
+util_format_ai44_fetch_rgba_float(float *dst, const uint8_t *src,
+ unsigned i, unsigned j) {}
diff --git a/mesalib/src/gallium/auxiliary/util/u_format_yuv.h b/mesalib/src/gallium/auxiliary/util/u_format_yuv.h
index d2c403ded..9f2365a52 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format_yuv.h
+++ b/mesalib/src/gallium/auxiliary/util/u_format_yuv.h
@@ -1,223 +1,358 @@
-/**************************************************************************
- *
- * Copyright 2010 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- **************************************************************************/
-
-
-/**
- * @file
- * YUV colorspace conversion.
- *
- * @author Brian Paul <brianp@vmware.com>
- * @author Michal Krol <michal@vmware.com>
- * @author Jose Fonseca <jfonseca@vmware.com>
- *
- * See also:
- * - http://www.fourcc.org/fccyvrgb.php
- * - http://msdn.microsoft.com/en-us/library/ms893078
- * - http://en.wikipedia.org/wiki/YUV
- */
-
-
-#ifndef U_FORMAT_YUV_H_
-#define U_FORMAT_YUV_H_
-
-
-#include "pipe/p_compiler.h"
-#include "u_math.h"
-
-
-/*
- * TODO: Ensure we use consistent and right floating formulas, with enough
- * precision in the coefficients.
- */
-
-static INLINE void
-util_format_rgb_float_to_yuv(float r, float g, float b,
- uint8_t *y, uint8_t *u, uint8_t *v)
-{
- const float _r = CLAMP(r, 0.0f, 1.0f);
- const float _g = CLAMP(g, 0.0f, 1.0f);
- const float _b = CLAMP(b, 0.0f, 1.0f);
-
- const float scale = 255.0f;
-
- const int _y = scale * ( (0.257f * _r) + (0.504f * _g) + (0.098f * _b));
- const int _u = scale * (-(0.148f * _r) - (0.291f * _g) + (0.439f * _b));
- const int _v = scale * ( (0.439f * _r) - (0.368f * _g) - (0.071f * _b));
-
- *y = _y + 16;
- *u = _u + 128;
- *v = _v + 128;
-}
-
-
-static INLINE void
-util_format_yuv_to_rgb_float(uint8_t y, uint8_t u, uint8_t v,
- float *r, float *g, float *b)
-{
- const int _y = y - 16;
- const int _u = u - 128;
- const int _v = v - 128;
-
- const float y_factor = 255.0f / 219.0f;
-
- const float scale = 1.0f / 255.0f;
-
- *r = scale * (y_factor * _y + 1.596f * _v);
- *g = scale * (y_factor * _y - 0.391f * _u - 0.813f * _v);
- *b = scale * (y_factor * _y + 2.018f * _u );
-}
-
-
-static INLINE void
-util_format_rgb_8unorm_to_yuv(uint8_t r, uint8_t g, uint8_t b,
- uint8_t *y, uint8_t *u, uint8_t *v)
-{
- *y = (( 66 * r + 129 * g + 25 * b + 128) >> 8) + 16;
- *u = (( -38 * r - 74 * g + 112 * b + 128) >> 8) + 128;
- *v = (( 112 * r - 94 * g - 18 * b + 128) >> 8) + 128;
-}
-
-
-static INLINE void
-util_format_yuv_to_rgb_8unorm(uint8_t y, uint8_t u, uint8_t v,
- uint8_t *r, uint8_t *g, uint8_t *b)
-{
- const int _y = y - 16;
- const int _u = u - 128;
- const int _v = v - 128;
-
- const int _r = (298 * _y + 409 * _v + 128) >> 8;
- const int _g = (298 * _y - 100 * _u - 208 * _v + 128) >> 8;
- const int _b = (298 * _y + 516 * _u + 128) >> 8;
-
- *r = CLAMP(_r, 0, 255);
- *g = CLAMP(_g, 0, 255);
- *b = CLAMP(_b, 0, 255);
-}
-
-
-
-void
-util_format_uyvy_unpack_rgba_float(float *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height);
-
-void
-util_format_uyvy_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height);
-
-void
-util_format_uyvy_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
- const float *src_row, unsigned src_stride,
- unsigned width, unsigned height);
-
-void
-util_format_uyvy_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height);
-
-void
-util_format_uyvy_fetch_rgba_float(float *dst, const uint8_t *src,
- unsigned i, unsigned j);
-
-void
-util_format_yuyv_unpack_rgba_float(float *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height);
-
-void
-util_format_yuyv_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height);
-
-void
-util_format_yuyv_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
- const float *src_row, unsigned src_stride,
- unsigned width, unsigned height);
-
-void
-util_format_yuyv_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height);
-
-void
-util_format_yuyv_fetch_rgba_float(float *dst, const uint8_t *src,
- unsigned i, unsigned j);
-
-
-void
-util_format_r8g8_b8g8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height);
-
-void
-util_format_r8g8_b8g8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height);
-
-void
-util_format_r8g8_b8g8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
- const float *src_row, unsigned src_stride,
- unsigned width, unsigned height);
-
-void
-util_format_r8g8_b8g8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height);
-
-void
-util_format_r8g8_b8g8_unorm_fetch_rgba_float(float *dst, const uint8_t *src,
- unsigned i, unsigned j);
-
-void
-util_format_g8r8_g8b8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height);
-
-void
-util_format_g8r8_g8b8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height);
-
-void
-util_format_g8r8_g8b8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
- const float *src_row, unsigned src_stride,
- unsigned width, unsigned height);
-
-void
-util_format_g8r8_g8b8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height);
-
-void
-util_format_g8r8_g8b8_unorm_fetch_rgba_float(float *dst, const uint8_t *src,
- unsigned i, unsigned j);
-
-
-
-#endif /* U_FORMAT_YUV_H_ */
+/**************************************************************************
+ *
+ * Copyright 2010 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ **************************************************************************/
+
+
+/**
+ * @file
+ * YUV colorspace conversion.
+ *
+ * @author Brian Paul <brianp@vmware.com>
+ * @author Michal Krol <michal@vmware.com>
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ *
+ * See also:
+ * - http://www.fourcc.org/fccyvrgb.php
+ * - http://msdn.microsoft.com/en-us/library/ms893078
+ * - http://en.wikipedia.org/wiki/YUV
+ */
+
+
+#ifndef U_FORMAT_YUV_H_
+#define U_FORMAT_YUV_H_
+
+
+#include "pipe/p_compiler.h"
+#include "u_math.h"
+
+
+/*
+ * TODO: Ensure we use consistent and right floating formulas, with enough
+ * precision in the coefficients.
+ */
+
+static INLINE void
+util_format_rgb_float_to_yuv(float r, float g, float b,
+ uint8_t *y, uint8_t *u, uint8_t *v)
+{
+ const float _r = CLAMP(r, 0.0f, 1.0f);
+ const float _g = CLAMP(g, 0.0f, 1.0f);
+ const float _b = CLAMP(b, 0.0f, 1.0f);
+
+ const float scale = 255.0f;
+
+ const int _y = scale * ( (0.257f * _r) + (0.504f * _g) + (0.098f * _b));
+ const int _u = scale * (-(0.148f * _r) - (0.291f * _g) + (0.439f * _b));
+ const int _v = scale * ( (0.439f * _r) - (0.368f * _g) - (0.071f * _b));
+
+ *y = _y + 16;
+ *u = _u + 128;
+ *v = _v + 128;
+}
+
+
+static INLINE void
+util_format_yuv_to_rgb_float(uint8_t y, uint8_t u, uint8_t v,
+ float *r, float *g, float *b)
+{
+ const int _y = y - 16;
+ const int _u = u - 128;
+ const int _v = v - 128;
+
+ const float y_factor = 255.0f / 219.0f;
+
+ const float scale = 1.0f / 255.0f;
+
+ *r = scale * (y_factor * _y + 1.596f * _v);
+ *g = scale * (y_factor * _y - 0.391f * _u - 0.813f * _v);
+ *b = scale * (y_factor * _y + 2.018f * _u );
+}
+
+
+static INLINE void
+util_format_rgb_8unorm_to_yuv(uint8_t r, uint8_t g, uint8_t b,
+ uint8_t *y, uint8_t *u, uint8_t *v)
+{
+ *y = (( 66 * r + 129 * g + 25 * b + 128) >> 8) + 16;
+ *u = (( -38 * r - 74 * g + 112 * b + 128) >> 8) + 128;
+ *v = (( 112 * r - 94 * g - 18 * b + 128) >> 8) + 128;
+}
+
+
+static INLINE void
+util_format_yuv_to_rgb_8unorm(uint8_t y, uint8_t u, uint8_t v,
+ uint8_t *r, uint8_t *g, uint8_t *b)
+{
+ const int _y = y - 16;
+ const int _u = u - 128;
+ const int _v = v - 128;
+
+ const int _r = (298 * _y + 409 * _v + 128) >> 8;
+ const int _g = (298 * _y - 100 * _u - 208 * _v + 128) >> 8;
+ const int _b = (298 * _y + 516 * _u + 128) >> 8;
+
+ *r = CLAMP(_r, 0, 255);
+ *g = CLAMP(_g, 0, 255);
+ *b = CLAMP(_b, 0, 255);
+}
+
+
+
+void
+util_format_uyvy_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+
+void
+util_format_uyvy_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+
+void
+util_format_uyvy_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+
+void
+util_format_uyvy_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+
+void
+util_format_uyvy_fetch_rgba_float(float *dst, const uint8_t *src,
+ unsigned i, unsigned j);
+
+void
+util_format_yuyv_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+
+void
+util_format_yuyv_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+
+void
+util_format_yuyv_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+
+void
+util_format_yuyv_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+
+void
+util_format_yuyv_fetch_rgba_float(float *dst, const uint8_t *src,
+ unsigned i, unsigned j);
+
+/* XXX: Stubbed for now */
+void
+util_format_yv12_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_yv12_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_yv12_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_yv12_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_yv12_fetch_rgba_float(float *dst, const uint8_t *src,
+ unsigned i, unsigned j);
+void
+util_format_yv16_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_yv16_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_yv16_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_yv16_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_yv16_fetch_rgba_float(float *dst, const uint8_t *src,
+ unsigned i, unsigned j);
+void
+util_format_iyuv_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_iyuv_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_iyuv_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_iyuv_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_iyuv_fetch_rgba_float(float *dst, const uint8_t *src,
+ unsigned i, unsigned j);
+void
+util_format_nv12_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_nv12_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_nv12_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_nv12_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_nv12_fetch_rgba_float(float *dst, const uint8_t *src,
+ unsigned i, unsigned j);
+void
+util_format_nv21_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_nv21_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_nv21_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_nv21_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_nv21_fetch_rgba_float(float *dst, const uint8_t *src,
+ unsigned i, unsigned j);
+void
+util_format_ia44_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_ia44_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_ia44_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_ia44_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_ia44_fetch_rgba_float(float *dst, const uint8_t *src,
+ unsigned i, unsigned j);
+void
+util_format_ai44_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_ai44_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_ai44_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_ai44_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+void
+util_format_ai44_fetch_rgba_float(float *dst, const uint8_t *src,
+ unsigned i, unsigned j);
+
+
+void
+util_format_r8g8_b8g8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+
+void
+util_format_r8g8_b8g8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+
+void
+util_format_r8g8_b8g8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+
+void
+util_format_r8g8_b8g8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+
+void
+util_format_r8g8_b8g8_unorm_fetch_rgba_float(float *dst, const uint8_t *src,
+ unsigned i, unsigned j);
+
+void
+util_format_g8r8_g8b8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+
+void
+util_format_g8r8_g8b8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+
+void
+util_format_g8r8_g8b8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+ const float *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+
+void
+util_format_g8r8_g8b8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+ const uint8_t *src_row, unsigned src_stride,
+ unsigned width, unsigned height);
+
+void
+util_format_g8r8_g8b8_unorm_fetch_rgba_float(float *dst, const uint8_t *src,
+ unsigned i, unsigned j);
+
+
+
+#endif /* U_FORMAT_YUV_H_ */
diff --git a/mesalib/src/gallium/auxiliary/util/u_upload_mgr.c b/mesalib/src/gallium/auxiliary/util/u_upload_mgr.c
index e50db6d67..71fe53e3a 100644
--- a/mesalib/src/gallium/auxiliary/util/u_upload_mgr.c
+++ b/mesalib/src/gallium/auxiliary/util/u_upload_mgr.c
@@ -257,7 +257,7 @@ enum pipe_error u_upload_buffer( struct u_upload_mgr *upload,
ret = u_upload_data( upload,
min_out_offset,
size,
- map,
+ map + offset,
out_offset,
outbuf, flushed );
diff --git a/mesalib/src/gallium/auxiliary/util/u_video.h b/mesalib/src/gallium/auxiliary/util/u_video.h
new file mode 100644
index 000000000..46da13610
--- /dev/null
+++ b/mesalib/src/gallium/auxiliary/util/u_video.h
@@ -0,0 +1,75 @@
+/**************************************************************************
+ *
+ * Copyright 2009 Younes Manton.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef U_VIDEO_H
+#define U_VIDEO_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <pipe/p_defines.h>
+
+/* u_reduce_video_profile() needs these */
+#include <pipe/p_compiler.h>
+#include <util/u_debug.h>
+
+static INLINE enum pipe_video_codec
+u_reduce_video_profile(enum pipe_video_profile profile)
+{
+ switch (profile)
+ {
+ case PIPE_VIDEO_PROFILE_MPEG1:
+ case PIPE_VIDEO_PROFILE_MPEG2_SIMPLE:
+ case PIPE_VIDEO_PROFILE_MPEG2_MAIN:
+ return PIPE_VIDEO_CODEC_MPEG12;
+
+ case PIPE_VIDEO_PROFILE_MPEG4_SIMPLE:
+ case PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE:
+ return PIPE_VIDEO_CODEC_MPEG4;
+
+ case PIPE_VIDEO_PROFILE_VC1_SIMPLE:
+ case PIPE_VIDEO_PROFILE_VC1_MAIN:
+ case PIPE_VIDEO_PROFILE_VC1_ADVANCED:
+ return PIPE_VIDEO_CODEC_VC1;
+
+ case PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE:
+ case PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN:
+ case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH:
+ return PIPE_VIDEO_CODEC_MPEG4_AVC;
+
+ default:
+ assert(0);
+ return PIPE_VIDEO_CODEC_UNKNOWN;
+ }
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* U_VIDEO_H */
diff --git a/mesalib/src/mesa/main/texfetch_tmp.h b/mesalib/src/mesa/main/texfetch_tmp.h
index 3b1eedf39..d170adf2e 100644
--- a/mesalib/src/mesa/main/texfetch_tmp.h
+++ b/mesalib/src/mesa/main/texfetch_tmp.h
@@ -2287,7 +2287,8 @@ static void FETCH(f_z24_s8)( const struct gl_texture_image *texImage,
const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
const GLfloat scale = 1.0F / (GLfloat) 0xffffff;
texel[0] = ((*src) >> 8) * scale;
- ASSERT(texImage->TexFormat == MESA_FORMAT_Z24_S8);
+ ASSERT(texImage->TexFormat == MESA_FORMAT_Z24_S8 ||
+ texImage->TexFormat == MESA_FORMAT_Z24_X8);
ASSERT(texel[0] >= 0.0F);
ASSERT(texel[0] <= 1.0F);
}
@@ -2314,7 +2315,8 @@ static void FETCH(f_s8_z24)( const struct gl_texture_image *texImage,
const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
const GLfloat scale = 1.0F / (GLfloat) 0xffffff;
texel[0] = ((*src) & 0x00ffffff) * scale;
- ASSERT(texImage->TexFormat == MESA_FORMAT_S8_Z24);
+ ASSERT(texImage->TexFormat == MESA_FORMAT_S8_Z24 ||
+ texImage->TexFormat == MESA_FORMAT_X8_Z24);
ASSERT(texel[0] >= 0.0F);
ASSERT(texel[0] <= 1.0F);
}
diff --git a/mesalib/src/mesa/state_tracker/st_cb_condrender.c b/mesalib/src/mesa/state_tracker/st_cb_condrender.c
index 64c6c117f..1ced560e1 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_condrender.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_condrender.c
@@ -41,6 +41,7 @@
#include "st_context.h"
#include "st_cb_queryobj.h"
#include "st_cb_condrender.h"
+#include "st_cb_bitmap.h"
/**
@@ -55,6 +56,8 @@ st_BeginConditionalRender(struct gl_context *ctx, struct gl_query_object *q,
struct pipe_context *pipe = st->pipe;
uint m;
+ st_flush_bitmap_cache(st);
+
switch (mode) {
case GL_QUERY_WAIT:
m = PIPE_RENDER_COND_WAIT;
@@ -90,6 +93,8 @@ st_EndConditionalRender(struct gl_context *ctx, struct gl_query_object *q)
struct pipe_context *pipe = st->pipe;
(void) q;
+ st_flush_bitmap_cache(st);
+
pipe->render_condition(pipe, NULL, 0);
st->render_condition = NULL;
}
diff --git a/mesalib/src/mesa/state_tracker/st_cb_queryobj.c b/mesalib/src/mesa/state_tracker/st_cb_queryobj.c
index 1efcaf593..057499615 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_queryobj.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_queryobj.c
@@ -1,179 +1,184 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-/**
- * glBegin/EndQuery interface to pipe
- *
- * \author Brian Paul
- */
-
-
-#include "main/imports.h"
-#include "main/context.h"
-#include "main/mfeatures.h"
-
-#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
-#include "st_context.h"
-#include "st_cb_queryobj.h"
-
-
-#if FEATURE_queryobj
-
-static struct gl_query_object *
-st_NewQueryObject(struct gl_context *ctx, GLuint id)
-{
- struct st_query_object *stq = ST_CALLOC_STRUCT(st_query_object);
- if (stq) {
- stq->base.Id = id;
- stq->base.Ready = GL_TRUE;
- stq->pq = NULL;
- stq->type = PIPE_QUERY_TYPES; /* an invalid value */
- return &stq->base;
- }
- return NULL;
-}
-
-
-
-static void
-st_DeleteQuery(struct gl_context *ctx, struct gl_query_object *q)
-{
- struct pipe_context *pipe = st_context(ctx)->pipe;
- struct st_query_object *stq = st_query_object(q);
-
- if (stq->pq) {
- pipe->destroy_query(pipe, stq->pq);
- stq->pq = NULL;
- }
-
- free(stq);
-}
-
-
-static void
-st_BeginQuery(struct gl_context *ctx, struct gl_query_object *q)
-{
- struct pipe_context *pipe = st_context(ctx)->pipe;
- struct st_query_object *stq = st_query_object(q);
- unsigned type;
-
- /* convert GL query type to Gallium query type */
- switch (q->Target) {
- case GL_ANY_SAMPLES_PASSED:
- /* fall-through */
- case GL_SAMPLES_PASSED_ARB:
- type = PIPE_QUERY_OCCLUSION_COUNTER;
- break;
- case GL_PRIMITIVES_GENERATED:
- type = PIPE_QUERY_PRIMITIVES_GENERATED;
- break;
- case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:
- type = PIPE_QUERY_PRIMITIVES_EMITTED;
- break;
- case GL_TIME_ELAPSED_EXT:
- type = PIPE_QUERY_TIME_ELAPSED;
- break;
- default:
- assert(0 && "unexpected query target in st_BeginQuery()");
- return;
- }
-
- if (stq->pq && stq->type != type) {
- /* free old query of different type */
- pipe->destroy_query(pipe, stq->pq);
- stq->pq = NULL;
- stq->type = PIPE_QUERY_TYPES; /* an invalid value */
- }
-
- if (!stq->pq) {
- stq->pq = pipe->create_query(pipe, type);
- stq->type = type;
- }
-
- assert(stq->type == type);
-
- pipe->begin_query(pipe, stq->pq);
-}
-
-
-static void
-st_EndQuery(struct gl_context *ctx, struct gl_query_object *q)
-{
- struct pipe_context *pipe = st_context(ctx)->pipe;
- struct st_query_object *stq = st_query_object(q);
-
- pipe->end_query(pipe, stq->pq);
-}
-
-
-static void
-st_WaitQuery(struct gl_context *ctx, struct gl_query_object *q)
-{
- struct pipe_context *pipe = st_context(ctx)->pipe;
- struct st_query_object *stq = st_query_object(q);
-
- /* this function should only be called if we don't have a ready result */
- assert(!stq->base.Ready);
-
- while (!stq->base.Ready &&
- !pipe->get_query_result(pipe,
- stq->pq,
- TRUE,
- &q->Result))
- {
- /* nothing */
- }
-
- q->Ready = GL_TRUE;
-}
-
-
-static void
-st_CheckQuery(struct gl_context *ctx, struct gl_query_object *q)
-{
- struct pipe_context *pipe = st_context(ctx)->pipe;
- struct st_query_object *stq = st_query_object(q);
- assert(!q->Ready); /* we should not get called if Ready is TRUE */
- q->Ready = pipe->get_query_result(pipe, stq->pq, FALSE, &q->Result);
-}
-
-
-
-
-void st_init_query_functions(struct dd_function_table *functions)
-{
- functions->NewQueryObject = st_NewQueryObject;
- functions->DeleteQuery = st_DeleteQuery;
- functions->BeginQuery = st_BeginQuery;
- functions->EndQuery = st_EndQuery;
- functions->WaitQuery = st_WaitQuery;
- functions->CheckQuery = st_CheckQuery;
-}
-
-#endif /* FEATURE_queryobj */
+/**************************************************************************
+ *
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+/**
+ * glBegin/EndQuery interface to pipe
+ *
+ * \author Brian Paul
+ */
+
+
+#include "main/imports.h"
+#include "main/context.h"
+#include "main/mfeatures.h"
+
+#include "pipe/p_context.h"
+#include "pipe/p_defines.h"
+#include "st_context.h"
+#include "st_cb_queryobj.h"
+#include "st_cb_bitmap.h"
+
+
+#if FEATURE_queryobj
+
+static struct gl_query_object *
+st_NewQueryObject(struct gl_context *ctx, GLuint id)
+{
+ struct st_query_object *stq = ST_CALLOC_STRUCT(st_query_object);
+ if (stq) {
+ stq->base.Id = id;
+ stq->base.Ready = GL_TRUE;
+ stq->pq = NULL;
+ stq->type = PIPE_QUERY_TYPES; /* an invalid value */
+ return &stq->base;
+ }
+ return NULL;
+}
+
+
+
+static void
+st_DeleteQuery(struct gl_context *ctx, struct gl_query_object *q)
+{
+ struct pipe_context *pipe = st_context(ctx)->pipe;
+ struct st_query_object *stq = st_query_object(q);
+
+ if (stq->pq) {
+ pipe->destroy_query(pipe, stq->pq);
+ stq->pq = NULL;
+ }
+
+ free(stq);
+}
+
+
+static void
+st_BeginQuery(struct gl_context *ctx, struct gl_query_object *q)
+{
+ struct pipe_context *pipe = st_context(ctx)->pipe;
+ struct st_query_object *stq = st_query_object(q);
+ unsigned type;
+
+ st_flush_bitmap_cache(st_context(ctx));
+
+ /* convert GL query type to Gallium query type */
+ switch (q->Target) {
+ case GL_ANY_SAMPLES_PASSED:
+ /* fall-through */
+ case GL_SAMPLES_PASSED_ARB:
+ type = PIPE_QUERY_OCCLUSION_COUNTER;
+ break;
+ case GL_PRIMITIVES_GENERATED:
+ type = PIPE_QUERY_PRIMITIVES_GENERATED;
+ break;
+ case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:
+ type = PIPE_QUERY_PRIMITIVES_EMITTED;
+ break;
+ case GL_TIME_ELAPSED_EXT:
+ type = PIPE_QUERY_TIME_ELAPSED;
+ break;
+ default:
+ assert(0 && "unexpected query target in st_BeginQuery()");
+ return;
+ }
+
+ if (stq->pq && stq->type != type) {
+ /* free old query of different type */
+ pipe->destroy_query(pipe, stq->pq);
+ stq->pq = NULL;
+ stq->type = PIPE_QUERY_TYPES; /* an invalid value */
+ }
+
+ if (!stq->pq) {
+ stq->pq = pipe->create_query(pipe, type);
+ stq->type = type;
+ }
+
+ assert(stq->type == type);
+
+ pipe->begin_query(pipe, stq->pq);
+}
+
+
+static void
+st_EndQuery(struct gl_context *ctx, struct gl_query_object *q)
+{
+ struct pipe_context *pipe = st_context(ctx)->pipe;
+ struct st_query_object *stq = st_query_object(q);
+
+ st_flush_bitmap_cache(st_context(ctx));
+
+ pipe->end_query(pipe, stq->pq);
+}
+
+
+static void
+st_WaitQuery(struct gl_context *ctx, struct gl_query_object *q)
+{
+ struct pipe_context *pipe = st_context(ctx)->pipe;
+ struct st_query_object *stq = st_query_object(q);
+
+ /* this function should only be called if we don't have a ready result */
+ assert(!stq->base.Ready);
+
+ while (!stq->base.Ready &&
+ !pipe->get_query_result(pipe,
+ stq->pq,
+ TRUE,
+ &q->Result))
+ {
+ /* nothing */
+ }
+
+ q->Ready = GL_TRUE;
+}
+
+
+static void
+st_CheckQuery(struct gl_context *ctx, struct gl_query_object *q)
+{
+ struct pipe_context *pipe = st_context(ctx)->pipe;
+ struct st_query_object *stq = st_query_object(q);
+ assert(!q->Ready); /* we should not get called if Ready is TRUE */
+ q->Ready = pipe->get_query_result(pipe, stq->pq, FALSE, &q->Result);
+}
+
+
+
+
+void st_init_query_functions(struct dd_function_table *functions)
+{
+ functions->NewQueryObject = st_NewQueryObject;
+ functions->DeleteQuery = st_DeleteQuery;
+ functions->BeginQuery = st_BeginQuery;
+ functions->EndQuery = st_EndQuery;
+ functions->WaitQuery = st_WaitQuery;
+ functions->CheckQuery = st_CheckQuery;
+}
+
+#endif /* FEATURE_queryobj */
diff --git a/mesalib/src/mesa/state_tracker/st_context.c b/mesalib/src/mesa/state_tracker/st_context.c
index 6eddbfc88..6d4bc544d 100644
--- a/mesalib/src/mesa/state_tracker/st_context.c
+++ b/mesalib/src/mesa/state_tracker/st_context.c
@@ -179,6 +179,9 @@ struct st_context *st_create_context(gl_api api, struct pipe_context *pipe,
st_init_driver_functions(&funcs);
ctx = _mesa_create_context(api, visual, shareCtx, &funcs, NULL);
+ if (!ctx) {
+ return NULL;
+ }
/* XXX: need a capability bit in gallium to query if the pipe
* driver prefers DP4 or MUL/MAD for vertex transformation.