Am 11.08.2014 04:21, schrieb Ilia Mirkin:
> Signed-off-by: Ilia Mirkin <imir...@alum.mit.edu>
> ---
> 
> v1 -> v2:
>  - add cases to util_format_srgb and util_format_linear
>  - remove special SRGBA case from util_format_fits_8unorm
> 
> Not sure if I should rename the SRGBA one to not have a _UNORM ending...
Might be a bit more consistent - none of the other formats use _UNORM if
they are a SRGB. Then again the non-srgb s3tc formats don't indicate
_UNORM... So I don't really have a strong opinion on it.

Roland

> 
>  src/gallium/auxiliary/Makefile.sources       |   1 +
>  src/gallium/auxiliary/util/u_format.c        |   4 +
>  src/gallium/auxiliary/util/u_format.csv      |   6 ++
>  src/gallium/auxiliary/util/u_format.h        |  12 ++-
>  src/gallium/auxiliary/util/u_format_bptc.c   |  26 +++++++
>  src/gallium/auxiliary/util/u_format_bptc.h   | 109 
> +++++++++++++++++++++++++++
>  src/gallium/auxiliary/util/u_format_pack.py  |   2 +-
>  src/gallium/auxiliary/util/u_format_table.py |   3 +-
>  src/gallium/include/pipe/p_format.h          |   5 ++
>  9 files changed, 165 insertions(+), 3 deletions(-)
>  create mode 100644 src/gallium/auxiliary/util/u_format_bptc.c
>  create mode 100644 src/gallium/auxiliary/util/u_format_bptc.h
> 
> diff --git a/src/gallium/auxiliary/Makefile.sources 
> b/src/gallium/auxiliary/Makefile.sources
> index 3eae9e5..9bfaa0e 100644
> --- a/src/gallium/auxiliary/Makefile.sources
> +++ b/src/gallium/auxiliary/Makefile.sources
> @@ -113,6 +113,7 @@ C_SOURCES := \
>       util/u_format_s3tc.c \
>       util/u_format_rgtc.c \
>       util/u_format_etc.c \
> +     util/u_format_bptc.c \
>       util/u_format_tests.c \
>       util/u_format_yuv.c \
>       util/u_format_zs.c \
> diff --git a/src/gallium/auxiliary/util/u_format.c 
> b/src/gallium/auxiliary/util/u_format.c
> index a53ed6f..d53dd78 100644
> --- a/src/gallium/auxiliary/util/u_format.c
> +++ b/src/gallium/auxiliary/util/u_format.c
> @@ -496,6 +496,10 @@ util_format_fits_8unorm(const struct 
> util_format_description *format_desc)
>            format_desc->format == PIPE_FORMAT_LATC2_SNORM)
>           return FALSE;
>        return TRUE;
> +   case UTIL_FORMAT_LAYOUT_BPTC:
> +      if (format_desc->format == PIPE_FORMAT_BPTC_RGBA_UNORM)
> +         return TRUE;
> +      return FALSE;
>  
>     case UTIL_FORMAT_LAYOUT_PLAIN:
>        /*
> diff --git a/src/gallium/auxiliary/util/u_format.csv 
> b/src/gallium/auxiliary/util/u_format.csv
> index 8aa5c36..570ea5a 100644
> --- a/src/gallium/auxiliary/util/u_format.csv
> +++ b/src/gallium/auxiliary/util/u_format.csv
> @@ -160,6 +160,7 @@ PIPE_FORMAT_R8G8Bx_SNORM          , other,      1,  1, 
> sn8 , sn8 ,     ,     , x
>  # - 
> https://urldefense.proofpoint.com/v1/url?u=http://www.opengl.org/registry/specs/EXT/texture_compression_s3tc.txt&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=F4msKE2WxRzA%2BwN%2B25muztFm5TSPwE8HKJfWfR2NgfY%3D%0A&m=Yn94d%2BRp75DLqLHeilmNN610EkZ2EySAnofhC69urfY%3D%0A&s=40a34c7195ec41ebd13a520dff825c27500b33b46ac6b98ecd3e9296338ecb4b
>  # - 
> https://urldefense.proofpoint.com/v1/url?u=http://www.opengl.org/registry/specs/ARB/texture_compression_rgtc.txt&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=F4msKE2WxRzA%2BwN%2B25muztFm5TSPwE8HKJfWfR2NgfY%3D%0A&m=Yn94d%2BRp75DLqLHeilmNN610EkZ2EySAnofhC69urfY%3D%0A&s=d8a10de0f76a1875e9841f7f1616e8dde3a44fcf45c680ba31c53f639e12f07f
>  # - 
> https://urldefense.proofpoint.com/v1/url?u=http://www.opengl.org/registry/specs/EXT/texture_compression_latc.txt&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=F4msKE2WxRzA%2BwN%2B25muztFm5TSPwE8HKJfWfR2NgfY%3D%0A&m=Yn94d%2BRp75DLqLHeilmNN610EkZ2EySAnofhC69urfY%3D%0A&s=e93386c2698529f3a71818b1781df50f2f628a20c10b7af80ecb8f3f77ceef66
> +# - 
> https://urldefense.proofpoint.com/v1/url?u=http://www.opengl.org/registry/specs/ARB/texture_compression_bptc.txt&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=F4msKE2WxRzA%2BwN%2B25muztFm5TSPwE8HKJfWfR2NgfY%3D%0A&m=Yn94d%2BRp75DLqLHeilmNN610EkZ2EySAnofhC69urfY%3D%0A&s=9812944304382f2b8902e050e6150f1ca798c289d8851c64708df77defd47ad3
>  # - 
> https://urldefense.proofpoint.com/v1/url?u=http://www.khronos.org/registry/gles/extensions/OES/OES_compressed_ETC1_RGB8_texture.txt&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=F4msKE2WxRzA%2BwN%2B25muztFm5TSPwE8HKJfWfR2NgfY%3D%0A&m=Yn94d%2BRp75DLqLHeilmNN610EkZ2EySAnofhC69urfY%3D%0A&s=5caa79b35402f269c07696017cc55a1490d30efa149b545c2efa8a024f99ee8f
>  # - 
> https://urldefense.proofpoint.com/v1/url?u=http://msdn.microsoft.com/en-us/library/bb694531.aspx&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=F4msKE2WxRzA%2BwN%2B25muztFm5TSPwE8HKJfWfR2NgfY%3D%0A&m=Yn94d%2BRp75DLqLHeilmNN610EkZ2EySAnofhC69urfY%3D%0A&s=1d29bb33841fd48deb20a7ff5cab8cc2f42af6e7d2461f66861b89afccde9af0
>  PIPE_FORMAT_DXT1_RGB              , s3tc, 4, 4, x64 ,     ,     ,     , 
> xyz1, rgb
> @@ -183,6 +184,11 @@ PIPE_FORMAT_LATC2_SNORM           , rgtc, 4, 4, x128,    
>  ,     ,     , xxxy, rg
>  
>  PIPE_FORMAT_ETC1_RGB8             ,  etc, 4, 4, x64,      ,     ,     , 
> xyz1, rgb
>  
> +PIPE_FORMAT_BPTC_RGBA_UNORM       , bptc, 4, 4, x128,     ,     ,     , 
> xyzw, rgb
> +PIPE_FORMAT_BPTC_SRGBA_UNORM      , bptc, 4, 4, x128,     ,     ,     , 
> xyzw, srgb
> +PIPE_FORMAT_BPTC_RGB_FLOAT        , bptc, 4, 4, x128,     ,     ,     , 
> xyz1, rgb
> +PIPE_FORMAT_BPTC_RGB_UFLOAT       , bptc, 4, 4, x128,     ,     ,     , 
> xyz1, rgb
> +
>  # Straightforward D3D10-like formats (also used for 
>  # vertex buffer element description)
>  # 
> diff --git a/src/gallium/auxiliary/util/u_format.h 
> b/src/gallium/auxiliary/util/u_format.h
> index 2e2bf02..93597ae 100644
> --- a/src/gallium/auxiliary/util/u_format.h
> +++ b/src/gallium/auxiliary/util/u_format.h
> @@ -79,9 +79,14 @@ enum util_format_layout {
>     UTIL_FORMAT_LAYOUT_ETC = 6,
>  
>     /**
> +    * BC6/7 Texture Compression
> +    */
> +   UTIL_FORMAT_LAYOUT_BPTC = 7,
Hmm. I'm beginning to wonder if it makes sense to have a different layout
for each family of compressed formats. IIRC the original distinction was
only made because s3tc formats needed to follow different code for
purely legal reasons...
But anyway, this isn't anything new so no objection.


> +   /**
>      * Everything else that doesn't fit in any of the above layouts.
>      */
> -   UTIL_FORMAT_LAYOUT_OTHER = 7
> +   UTIL_FORMAT_LAYOUT_OTHER = 8
>  };
>  
>  
> @@ -475,6 +480,7 @@ util_format_is_compressed(enum pipe_format format)
>     case UTIL_FORMAT_LAYOUT_S3TC:
>     case UTIL_FORMAT_LAYOUT_RGTC:
>     case UTIL_FORMAT_LAYOUT_ETC:
> +   case UTIL_FORMAT_LAYOUT_BPTC:
>        /* XXX add other formats in the future */
>        return TRUE;
>     default:
> @@ -911,6 +917,8 @@ util_format_srgb(enum pipe_format format)
>        return PIPE_FORMAT_DXT5_SRGBA;
>     case PIPE_FORMAT_B5G6R5_UNORM:
>        return PIPE_FORMAT_B5G6R5_SRGB;
> +   case PIPE_FORMAT_BPTC_RGBA_UNORM:
> +      return PIPE_FORMAT_BPTC_SRGBA_UNORM;
>     default:
>        return PIPE_FORMAT_NONE;
>     }
> @@ -956,6 +964,8 @@ util_format_linear(enum pipe_format format)
>        return PIPE_FORMAT_DXT5_RGBA;
>     case PIPE_FORMAT_B5G6R5_SRGB:
>        return PIPE_FORMAT_B5G6R5_UNORM;
> +   case PIPE_FORMAT_BPTC_SRGBA_UNORM:
> +      return PIPE_FORMAT_BPTC_RGBA_UNORM;
>     default:
>        return format;
>     }
> diff --git a/src/gallium/auxiliary/util/u_format_bptc.c 
> b/src/gallium/auxiliary/util/u_format_bptc.c
> new file mode 100644
> index 0000000..8fb002f
> --- /dev/null
> +++ b/src/gallium/auxiliary/util/u_format_bptc.c
> @@ -0,0 +1,26 @@
> +#include "u_format.h"
> +#include "u_format_bptc.h"
> +
> +#define fake(format) \
> +void \
> +util_format_##format##_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, 
> unsigned i, unsigned j) {assert(0);} \
> +\
> +void \
> +util_format_##format##_unpack_rgba_8unorm(uint8_t *dst_row, unsigned 
> dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, 
> unsigned height) {assert(0);} \
> +\
> +void \
> +util_format_##format##_pack_rgba_8unorm(uint8_t *dst_row, unsigned 
> dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, 
> unsigned height) {assert(0);} \
> +\
> +void \
> +util_format_##format##_unpack_rgba_float(float *dst_row, unsigned 
> dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, 
> unsigned height) {assert(0);} \
> +\
> +void \
> +util_format_##format##_pack_rgba_float(uint8_t *dst_row, unsigned 
> dst_stride, const float *src_row, unsigned src_stride, unsigned width, 
> unsigned height) {assert(0);} \
> +\
> +void \
> +util_format_##format##_fetch_rgba_float(float *dst, const uint8_t *src, 
> unsigned i, unsigned j) {assert(0);}
> +
> +fake(bptc_rgba_unorm)
> +fake(bptc_srgba_unorm)
> +fake(bptc_rgb_float)
> +fake(bptc_rgb_ufloat)
> diff --git a/src/gallium/auxiliary/util/u_format_bptc.h 
> b/src/gallium/auxiliary/util/u_format_bptc.h
> new file mode 100644
> index 0000000..77bedfd
> --- /dev/null
> +++ b/src/gallium/auxiliary/util/u_format_bptc.h
> @@ -0,0 +1,109 @@
> +/**************************************************************************
> + *
> + * Copyright 2011 Red Hat 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.
> + *
> + **************************************************************************/
> +
> +#ifndef U_FORMAT_BPTC_H_
> +#define U_FORMAT_BPTC_H_
> +
> +void
> +util_format_bptc_rgba_unorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t 
> *src, unsigned i, unsigned j);
> +
> +void
> +util_format_bptc_rgba_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_bptc_rgba_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_bptc_rgba_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_bptc_rgba_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_bptc_rgba_unorm_fetch_rgba_float(float *dst, const uint8_t *src, 
> unsigned i, unsigned j);
> +
> +
> +
> +void
> +util_format_bptc_srgba_unorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t 
> *src, unsigned i, unsigned j);
> +
> +void
> +util_format_bptc_srgba_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_bptc_srgba_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_bptc_srgba_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_bptc_srgba_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_bptc_srgba_unorm_fetch_rgba_float(float *dst, const uint8_t 
> *src, unsigned i, unsigned j);
> +
> +
> +
> +void
> +util_format_bptc_rgb_float_fetch_rgba_8unorm(uint8_t *dst, const uint8_t 
> *src, unsigned i, unsigned j);
> +
> +void
> +util_format_bptc_rgb_float_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_bptc_rgb_float_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_bptc_rgb_float_unpack_rgba_float(float *dst_row, unsigned 
> dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, 
> unsigned height);
> +
> +void
> +util_format_bptc_rgb_float_pack_rgba_float(uint8_t *dst_row, unsigned 
> dst_stride, const float *src_row, unsigned src_stride, unsigned width, 
> unsigned height);
> +
> +void
> +util_format_bptc_rgb_float_fetch_rgba_float(float *dst, const uint8_t *src, 
> unsigned i, unsigned j);
> +
> +
> +void
> +util_format_bptc_rgb_ufloat_fetch_rgba_8unorm(uint8_t *dst, const uint8_t 
> *src, unsigned i, unsigned j);
> +
> +void
> +util_format_bptc_rgb_ufloat_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_bptc_rgb_ufloat_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_bptc_rgb_ufloat_unpack_rgba_float(float *dst_row, unsigned 
> dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, 
> unsigned height);
> +
> +void
> +util_format_bptc_rgb_ufloat_pack_rgba_float(uint8_t *dst_row, unsigned 
> dst_stride, const float *src_row, unsigned src_stride, unsigned width, 
> unsigned height);
> +
> +void
> +util_format_bptc_rgb_ufloat_fetch_rgba_float(float *dst, const uint8_t *src, 
> unsigned i, unsigned j);
> +
> +
> +#endif
> diff --git a/src/gallium/auxiliary/util/u_format_pack.py 
> b/src/gallium/auxiliary/util/u_format_pack.py
> index a553e23..6ccf04c 100644
> --- a/src/gallium/auxiliary/util/u_format_pack.py
> +++ b/src/gallium/auxiliary/util/u_format_pack.py
> @@ -659,7 +659,7 @@ def generate_format_fetch(format, dst_channel, 
> dst_native_type, dst_suffix):
>  
>  
>  def is_format_hand_written(format):
> -    return format.layout in ('s3tc', 'rgtc', 'etc', 'subsampled', 'other') 
> or format.colorspace == ZS
> +    return format.layout in ('s3tc', 'rgtc', 'etc', 'bptc', 'subsampled', 
> 'other') or format.colorspace == ZS
>  
>  
>  def generate(formats):
> diff --git a/src/gallium/auxiliary/util/u_format_table.py 
> b/src/gallium/auxiliary/util/u_format_table.py
> index 81fd399..ad582e4 100755
> --- a/src/gallium/auxiliary/util/u_format_table.py
> +++ b/src/gallium/auxiliary/util/u_format_table.py
> @@ -90,6 +90,7 @@ def write_format_table(formats):
>      print '#include "u_format_rgtc.h"'
>      print '#include "u_format_latc.h"'
>      print '#include "u_format_etc.h"'
> +    print '#include "u_format_bptc.h"'
>      print
>      
>      u_format_pack.generate(formats)
> @@ -141,7 +142,7 @@ def write_format_table(formats):
>          if format.colorspace != ZS and not format.is_pure_color():
>              print "   &util_format_%s_unpack_rgba_8unorm," % 
> format.short_name() 
>              print "   &util_format_%s_pack_rgba_8unorm," % 
> format.short_name() 
> -            if format.layout == 's3tc' or format.layout == 'rgtc':
> +            if format.layout == 's3tc' or format.layout == 'rgtc' or 
> format.layout == 'bptc':
Not that this would be your bug but isn't that actually missing etc format?

>                  print "   &util_format_%s_fetch_rgba_8unorm," % 
> format.short_name()
>              else:
>                  print "   NULL, /* fetch_rgba_8unorm */" 
> diff --git a/src/gallium/include/pipe/p_format.h 
> b/src/gallium/include/pipe/p_format.h
> index a7fdcd0..a29b9d6 100644
> --- a/src/gallium/include/pipe/p_format.h
> +++ b/src/gallium/include/pipe/p_format.h
> @@ -344,6 +344,11 @@ enum pipe_format {
>  
>     PIPE_FORMAT_B5G6R5_SRGB             = 254,
>  
> +   PIPE_FORMAT_BPTC_RGBA_UNORM         = 255,
> +   PIPE_FORMAT_BPTC_SRGBA_UNORM        = 256,
> +   PIPE_FORMAT_BPTC_RGB_FLOAT          = 257,
> +   PIPE_FORMAT_BPTC_RGB_UFLOAT         = 258,
> +
>     PIPE_FORMAT_COUNT
>  };
>  
> 

For the series:
Reviewed-by: Roland Scheidegger <srol...@vmware.com>


_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to