[Mesa-dev] [PATCH 00/12] Rework texture upload code

Jason Ekstrand jason at jlekstrand.net
Thu Jul 17 11:04:22 PDT 2014

This is the first installment of some work I've been doing over the past
couple of weeks to refactor mesa's texture conversion/storage code.  There
is more to be done and more that I have done but have not included in this
series.  This is the first mailing-list-ready fruits of my efforts.  The
important bits here include:

 1) Using a human-readable CSV file to describe texture formats similar to
    the way it is currently don in gallium.  This is much easier to
    read/edit than the structure in formats.c.  The guts of formats.c is
    then autogenerated from this CSV file.

 2) Adding a very generic yet efficient _mesa_swizzle_and_convert function
    that is capable of performing the vast majority of texture format
    conversions in one function.  It has also been fairly carefully tuned
    to be even faster than the _mesa_swizzle_ubyte_image special-case that
    we had before for ubyte textures only it also works on the other
    datatypes and can even do type conversions as it swizzles.

 3) Refactoring of texstore.c including the use of the above
    _mesa_swizzle_and_convert function along with the already-existing
    packing functions to remove a lot of hand-written special-case code.

Thanks to the format CSV file, there's even more that we can now do.
Things I hope to accomplish in the future include:

 1) Autogenerate the bulk of main/format_pack.c, main/format_unpack.c, and
    main/pack.c from CSV files.  There's some refactoring that will be
    required first, but it shouldn't be that hard and I already have the
    python code to do the generation; it's just not part of this patch
 2) Find a general way to do depth-stencil formats.  I'm a bit dubious as
    to whether or not this will turn out to be practical, but I haven't had
    a chance to look into it too much yet.
 2) Do similar refactors for GetTexImage, ReadPixels, and DrawPixels.

Happy Reviewing!
--Jason Ekstrand

Jason Ekstrand (12):
  main: Add a format description CSV file
  main/formats: Autogenerate the format_info structure from a CSV file
  main/formats: Remove IndexBits
  main/formats: Add layout and swizzle information
  main: Gather some common format conversion functions into a single
    format_utils file
  main/format_utils: Add a general format conversion function
  main/format_utils: Add a function for determining if a format is
    actually     an array format and computing the array format
  main/texstore: Split texture storage into three functions:
    texstore_depth_stencil, texstore_compressed, and texstore_rgba
  main/texstore: Use _mesa_swizzle_and_convert when possible
  main/format_pack: Fix a wrong datatype in pack_ubyte_R8G8_UNORM
  main/texstore: Add a general texture upload path for rgba
    floating-point     and normalized textures
  mesa/texstore: Add a generic rgba integer texture upload path

 src/mesa/Makefile.am             |   10 +
 src/mesa/Makefile.sources        |    1 +
 src/mesa/main/.gitignore         |    1 +
 src/mesa/main/format_info.py     |  192 +++
 src/mesa/main/format_pack.c      |  104 +-
 src/mesa/main/format_parser.py   |  406 +++++
 src/mesa/main/format_unpack.c    |   69 +-
 src/mesa/main/format_unpack.h    |    3 -
 src/mesa/main/format_utils.c     |  715 +++++++++
 src/mesa/main/format_utils.h     |   90 ++
 src/mesa/main/formats.c          | 1786 +--------------------
 src/mesa/main/formats.csv        |  282 ++++
 src/mesa/main/formats.h          |   29 +
 src/mesa/main/texcompress_etc.c  |   20 +-
 src/mesa/main/texcompress_s3tc.c |   26 +-
 src/mesa/main/texstore.c         | 3172 +++++++-------------------------------
 16 files changed, 2412 insertions(+), 4494 deletions(-)
 create mode 100644 src/mesa/main/format_info.py
 create mode 100755 src/mesa/main/format_parser.py
 create mode 100644 src/mesa/main/format_utils.c
 create mode 100644 src/mesa/main/format_utils.h
 create mode 100644 src/mesa/main/formats.csv


More information about the mesa-dev mailing list