diff options
author | marha <marha@users.sourceforge.net> | 2011-07-14 16:15:03 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2011-07-14 16:15:03 +0200 |
commit | 31ee9c57db79281e122d3c4acb0f8eae07f4449f (patch) | |
tree | 222bc6f83ebdb15721e7acfdb829aa85606e243a /mesalib | |
parent | 8797d6ab8ef5121c900cd74b8662305ec7aeb34b (diff) | |
parent | d03a5f20114203fd00e0004659fd2617f4c03a32 (diff) | |
download | vcxsrv-31ee9c57db79281e122d3c4acb0f8eae07f4449f.tar.gz vcxsrv-31ee9c57db79281e122d3c4acb0f8eae07f4449f.tar.bz2 vcxsrv-31ee9c57db79281e122d3c4acb0f8eae07f4449f.zip |
Merge remote-tracking branch 'origin/released'
Conflicts:
mesalib/src/mesa/state_tracker/st_context.c
xorg-server/hw/xquartz/GL/indirect.c
xorg-server/hw/xwin/glx/indirect.c
xorg-server/hw/xwin/glx/wgl_ext_api.c
xorg-server/hw/xwin/glx/winpriv.c
xorg-server/hw/xwin/man/XWin.man
xorg-server/hw/xwin/winmultiwindowwindow.c
Diffstat (limited to 'mesalib')
-rw-r--r-- | mesalib/configs/autoconf.in | 6 | ||||
-rw-r--r-- | mesalib/configure.ac | 141 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_format.csv | 530 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_format_yuv.c | 2229 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_format_yuv.h | 581 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_upload_mgr.c | 2 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_video.h | 75 | ||||
-rw-r--r-- | mesalib/src/mesa/main/texfetch_tmp.h | 6 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_cb_condrender.c | 5 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_cb_queryobj.c | 363 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_context.c | 3 |
11 files changed, 2214 insertions, 1727 deletions
diff --git a/mesalib/configs/autoconf.in b/mesalib/configs/autoconf.in index cac4befe9..584f5fd77 100644 --- a/mesalib/configs/autoconf.in +++ b/mesalib/configs/autoconf.in @@ -183,6 +183,12 @@ DRI_DRIVER_SEARCH_DIR = @DRI_DRIVER_SEARCH_DIR@ # EGL driver install directory EGL_DRIVER_INSTALL_DIR = @EGL_DRIVER_INSTALL_DIR@ +# VDPAU library install directory +VDPAU_LIB_INSTALL_DIR=@VDPAU_LIB_INSTALL_DIR@ + +# VA library install directory +VA_LIB_INSTALL_DIR=@VA_LIB_INSTALL_DIR@ + # Xorg driver install directory (for xorg state-tracker) XORG_DRIVER_INSTALL_DIR = @XORG_DRIVER_INSTALL_DIR@ diff --git a/mesalib/configure.ac b/mesalib/configure.ac index eace790d8..c3047d622 100644 --- a/mesalib/configure.ac +++ b/mesalib/configure.ac @@ -586,6 +586,22 @@ AC_ARG_ENABLE([gbm], [enable_gbm="$enableval"], [enable_gbm=auto]) +AC_ARG_ENABLE([xvmc], + [AS_HELP_STRING([--enable-xvmc], + [enable xvmc library @<:@default=auto@:>@])], + [enable_xvmc="$enableval"], + [enable_xvmc=auto]) +AC_ARG_ENABLE([vdpau], + [AS_HELP_STRING([--enable-vdpau], + [enable vdpau library @<:@default=auto@:>@])], + [enable_vdpau="$enableval"], + [enable_vdpau=auto]) +AC_ARG_ENABLE([va], + [AS_HELP_STRING([--enable-va], + [enable va library @<:@default=auto@:>@])], + [enable_va="$enableval"], + [enable_va=auto]) + AC_ARG_ENABLE([xlib_glx], [AS_HELP_STRING([--enable-xlib-glx], [make GLX library Xlib-based instead of DRI-based @<:@default=disable@:>@])], @@ -630,7 +646,10 @@ if test "x$enable_opengl" = xno -a \ "x$enable_openvg" = xno -a \ "x$enable_xorg" = xno -a \ "x$enable_xa" = xno -a \ - "x$enable_d3d1x" = xno; then + "x$enable_d3d1x" = xno -a \ + "x$enable_xvmc" = xno -a \ + "x$enable_vdpau" = xno -a \ + "x$enable_va" = xno; then AC_MSG_ERROR([at least one API should be enabled]) fi @@ -750,7 +769,7 @@ GLU_DIRS="sgi" GALLIUM_DIRS="auxiliary drivers state_trackers" GALLIUM_TARGET_DIRS="" GALLIUM_WINSYS_DIRS="sw" -GALLIUM_DRIVERS_DIRS="softpipe failover galahad trace rbug noop identity" +GALLIUM_DRIVERS_DIRS="failover galahad trace rbug noop identity" GALLIUM_STATE_TRACKERS_DIRS="" # build shared-glapi if enabled for OpenGL or if OpenGL ES is enabled @@ -1479,6 +1498,56 @@ if test "x$enable_d3d1x" = xyes; then fi dnl +dnl Gallium G3DVL configuration +dnl +AC_ARG_ENABLE([gallium-g3dvl], + [AS_HELP_STRING([--enable-gallium-g3dvl], + [build gallium g3dvl @<:@default=disabled@:>@])], + [enable_gallium_g3dvl="$enableval"], + [enable_gallium_g3dvl=no]) +if test "x$enable_gallium_g3dvl" = xyes; then + if test "x$with_gallium_drivers" = x; then + AC_MSG_ERROR([cannot enable G3DVL without Gallium]) + fi + + if test "x$enable_xvmc" = xauto; then + enable_xvmc=yes + fi + + if test "x$enable_vdpau" = xauto; then + enable_vdpau=yes + fi + + if test "x$enable_va" = xauto; then + enable_va=no + fi +fi + +#TODO: Check for xvmc libs/headers +if test "x$enable_xvmc" = xyes; then + GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS xorg/xvmc" + HAVE_ST_XVMC="yes" +fi + +#TODO: Check for vdpau libs/headers +if test "x$enable_vdpau" = xyes; then + GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS vdpau" + HAVE_ST_VDPAU="yes" +fi + +#TODO: Check for va libs/headers +if test "x$enable_va" = xyes; then + GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS va" + HAVE_ST_VA="yes" +fi + +if test "x$enable_xvmc" = xyes || + test "x$enable_vdpau" = xyes || + test "x$enable_va" = xyes; then + GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS g3dvl/dri" +fi + +dnl dnl GLU configuration dnl AC_ARG_ENABLE([glu], @@ -1697,8 +1766,6 @@ AC_SUBST([LLVM_LIBS]) AC_SUBST([LLVM_LDFLAGS]) AC_SUBST([LLVM_VERSION]) - - case "x$enable_opengl$enable_gles1$enable_gles2" in x*yes*) EGL_CLIENT_APIS="$EGL_CLIENT_APIS "'$(GL_LIB)' @@ -1817,8 +1884,7 @@ if test "x$enable_gallium_llvm" = xyes; then LLVM_LIBS="`$LLVM_CONFIG --libs` -lstdc++" LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags` - GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS llvmpipe" - DEFINES="$DEFINES -DGALLIUM_LLVMPIPE -D__STDC_CONSTANT_MACROS" + DEFINES="$DEFINES -D__STDC_CONSTANT_MACROS" MESA_LLVM=1 else MESA_LLVM=0 @@ -1827,12 +1893,29 @@ else MESA_LLVM=0 fi +dnl Directory for VDPAU libs +AC_ARG_WITH([vdpau-libdir], + [AS_HELP_STRING([--with-vdpau-libdir=DIR], + [directory for the VDPAU libraries @<:@default=${libdir}/vdpau@:>@])], + [VDPAU_LIB_INSTALL_DIR="$withval"], + [VDPAU_LIB_INSTALL_DIR='${libdir}/vdpau']) +AC_SUBST([VDPAU_LIB_INSTALL_DIR]) + +dnl Directory for VA libs +AC_ARG_WITH([va-libdir], + [AS_HELP_STRING([--with-va-libdir=DIR], + [directory for the VA libraries @<:@default=${libdir}/va@:>@])], + [VA_LIB_INSTALL_DIR="$withval"], + [VA_LIB_INSTALL_DIR='${libdir}/va']) +AC_SUBST([VA_LIB_INSTALL_DIR]) + dnl dnl Gallium helper functions dnl gallium_check_st() { if test "x$HAVE_ST_DRI" = xyes || test "x$HAVE_ST_XORG" = xyes || - test "x$HAVE_ST_XA" = xyes; then + test "x$HAVE_ST_XA" = xyes || test "x$HAVE_ST_XVMC" = xyes || + test "x$HAVE_ST_VDPAU" = xyes || test "x$HAVE_ST_VA" = xyes; then if test "x$have_libdrm" != xyes; then AC_MSG_ERROR([DRI or Xorg DDX requires libdrm >= $LIBDRM_REQUIRED]) fi @@ -1847,6 +1930,15 @@ gallium_check_st() { if test "x$HAVE_ST_XA" = xyes && test "x$4" != x; then GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $4" fi + if test "x$HAVE_ST_XVMC" = xyes && test "x$5" != x; then + GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $5" + fi + if test "x$HAVE_ST_VDPAU" = xyes && test "x$6" != x; then + GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $6" + fi + if test "x$HAVE_ST_VA" = xyes && test "x$7" != x; then + GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $7" + fi } gallium_require_llvm() { @@ -1858,39 +1950,60 @@ gallium_require_llvm() { } dnl Gallium drivers +dnl Duplicates in GALLIUM_DRIVERS_DIRS are removed by sorting it after this block if test "x$with_gallium_drivers" != x; then - # This is for compile-testing - GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915 i965 r300 svga" - GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS i915/sw" - gallium_drivers=`IFS=', '; echo $with_gallium_drivers` for driver in $gallium_drivers; do case "x$driver" in xsvga) + GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga softpipe" gallium_check_st "svga/drm" "dri-vmwgfx" "xorg-vmwgfx" "xa-vmwgfx" ;; xi915) + GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915 softpipe" + if test "x$MESA_LLVM" = x1; then + GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS llvmpipe" + fi + GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS i915/sw" gallium_check_st "i915/drm" "dri-i915" "xorg-i915" ;; xi965) + GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i965 softpipe" + if test "x$MESA_LLVM" = x1; then + GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS llvmpipe" + fi gallium_check_st "i965/drm" "dri-i965" "xorg-i965" ;; xr300) gallium_require_llvm "Gallium R300" - gallium_check_st "radeon/drm" "dri-r300" "xorg-r300" + GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300" + gallium_check_st "radeon/drm" "dri-r300" "xorg-r300" "" "xvmc-r300" "vdpau-r300" "va-r300" ;; xr600) GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r600" - gallium_check_st "r600/drm" "dri-r600" + gallium_check_st "r600/drm" "dri-r600" "" "" "xvmc-r600" "vdpau-r600" "va-r600" ;; xnouveau) GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau nvfx nv50 nvc0" - gallium_check_st "nouveau/drm" "dri-nouveau" "xorg-nouveau" + gallium_check_st "nouveau/drm" "dri-nouveau" "xorg-nouveau" "" "xvmc-nouveau" ;; xswrast) if test "x$HAVE_ST_DRI" = xyes; then + GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS softpipe" + if test "x$MESA_LLVM" = x1; then + GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS llvmpipe" + fi GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri-swrast" fi + if test "x$HAVE_ST_VDPAU" = xyes; then + GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS vdpau-softpipe" + fi + if test "x$HAVE_ST_XVMC" = xyes; then + GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS xvmc-softpipe" + fi + if test "x$HAVE_ST_VA" = xyes; then + GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS va-softpipe" + fi ;; *) AC_MSG_ERROR([Unknown Gallium driver: $driver]) 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 40af1a5bb..b6a78daf6 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.
|