[Mesa-dev] [Bug 84566] New: Unify the format conversion code

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Wed Oct 1 13:33:01 PDT 2014


https://bugs.freedesktop.org/show_bug.cgi?id=84566

          Priority: medium
            Bug ID: 84566
          Assignee: mesa-dev at lists.freedesktop.org
           Summary: Unify the format conversion code
          Severity: enhancement
    Classification: Unclassified
                OS: All
          Reporter: jason at jlekstrand.net
          Hardware: All
            Status: NEW
           Version: git
         Component: Mesa core
           Product: Mesa

Right now we have a lot of format conversion code scattered all over mesa.  Off
the top of my head we have:

 * main/format_utils.c: Convert between two array based formats
 * main/format_pack.c: Convert from GLubyte and GLfloat array formats to mesa
formats
 * main/format_unpack.c: Convert from mesa formats to GLubyte, GLfloat, and
GLuint array formats
 * main/pack.c: Convert GL formats to/from GLubyte, GLfloat, and GLuint array
formats.  (This is redundant since all the GL formats are either array formats
or mesa formats)
 * main/texstore.c: Most of the stuff for color formats is gone, but depth and
stencil is still repeated.  Also, there's a terrible 565 path left there.
 * swrast/s_texfetch.c: Mostly a repeat of format_unpack.c
 * gallium/auxilliary/util/: More packing/unpacking functions that are repeats
of the above.

As you can see, there's a lot of repetition.  There's also several places where
we have the same repeated code to do full conversions.  It's a mess.

I would like to fix clean up this mess and unify a lot of the conversion code. 
Here's what I've envisioned:

 1) Autogenerate all of the color packing/unpacking functions
 2) Convert all of the packing/unpacking functions to pack/unpack a rectangle
taking a width, height, and stride.  We can use 1x1 for single-pixel
conversions.
 3) Make swrast use the unpacking functions instead of its own texture sampling
functions.
 4) Add an array format enum that allows us to enumerate all possible array
formats.  Between mesa_format and this array format, we should also be able to
enumerate all of the GL datatypes.
 5) Make a masater conversion function that takes a void*, format, width,
height, and stride for both source and destination and just does the
conversion.  If the above mentioned array format enum is distinct from the
mesa_format enum, the function could be written to take a uint32_t type and
accept either mesa_format or an array format in the same parameter.
 6) Use the above master conversion function for TexSubimage, TexImage,
GetTexImage, DrawPixels, and ReadPixels.  We still have to deal with pixel
conversion, but it should vastly simplify all of them.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20141001/999b4bc5/attachment-0001.html>


More information about the mesa-dev mailing list