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

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Fri Oct 10 07:01:48 PDT 2014


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

--- Comment #15 from Jason Ekstrand <jason at jlekstrand.net> ---
(In reply to Iago Toral from comment #14)
> (...)
> > > I don't know yet. For that I would have enable the master convertion
> > > function for all code paths, then run all the piglit tests and then check
> > > the cases that hit the assertion I have one by one removing duplicate cases,
> > > so it would take some time.
> > > 
> > > In any case, even if these were a significant bunch: do we have a good
> > > alternative? If we don't create mesa_formats for these types we would have
> > > to handle them as exceptions to the process (and this kind of defeats the
> > > purpose of a master function). We would have to handle conversions from and
> > > to these types through different paths and write the conversions functions
> > > we need by hand...
> > 
> > You should know once you write a gl_format_and_type_to_mesa_format function.
> 
> I have that already, but it is not enough. At the moment, if I have detected
> that a format is not an array format, I do something like this to decide if
> it has a matching mesa format:
> 
>    for (int f = 1; f < MESA_FORMAT_COUNT; f++)
>       if (_mesa_format_matches_format_and_type(f, format, type, swap_bytes))
>          return f;
> 
> So the cases that don't match simply continue and hit an assertion.

You should be able to do this with a simple switch statement.  There aren't
that many of them.  According to the GL 1.2 docs for TexImage, there are:

GL_UNSIGNED_BYTE_3_3_2
GL_UNSIGNED_BYTE_2_3_3_REV
GL_UNSIGNED_SHORT_5_6_5
GL_UNSIGNED_SHORT_5_6_5_REV
GL_UNSIGNED_SHORT_4_4_4_4
GL_UNSIGNED_SHORT_4_4_4_4_REV
GL_UNSIGNED_SHORT_5_5_5_1
GL_UNSIGNED_SHORT_1_5_5_5_REV
GL_UNSIGNED_INT_8_8_8_8
GL_UNSIGNED_INT_8_8_8_8_REV
GL_UNSIGNED_INT_10_10_10_2
GL_UNSIGNED_INT_2_10_10_10_REV

I think they added 1 or 2 more in extensions, but that should be it.  Also, you
have to watch out for GL_RGB vs. GL_BGR stuff

> > I don't think there will be many.  I think OpenGL only specifies about 8
> > packed formats (plus swizzling) and we should already have most of them.
> 
> Let's assume they are not that many then.
> 
> On a different note, I have just noticed that the driver can select a
> different texture format than the internal format specified by the client
> (glTexImage*), when the specified format is not supported. This creates a
> requirement for swizzle transformations where we need to do
> src->baseinternal->rgba->dst, but the master function, as it is right now,
> does not know about the internal format (only knows src and dst, so it does
> src->rgba->dst), so it fails for some of these cases.
> 
> For example, in one case I see that the client specifies MESA_FORMAT_I_SINT8
> (swizzle 0000) as the internal format for the texture, but the driver does
> not support that and uses MESA_FORMAT_RGBA_SINT8 (swizzle 0123) instead. A
> master function that only knows about MESA_FORMAT_RGBA_SINT8 and does not
> know that the format requested by the client was MESA_FORMAT_I_SINT8 will
> not produce correct results since it would not be able to compute the right
> swizzle transform for _mesa_swizzle_and_convert.
> 
> So my proposal is to pass the baseinternalformat to the master converter. If
> there are cases where we do not care about an internalformat we can just
> pass _mesa_get_format_base_format(dstFormat) and then have the master
> converter compute a different swizzle when the provided internal format is
> different from _mesa_get_format_base_format(dstFormat), which is what
> various parts of texstore are doing now.
> 
> Sounds reasonable?

Yes, we do need something for that.  Using the GL_RGB/RGBA enum would work
fine.  Another option would be to have an array of 4 bools that gives a channel
mask.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20141010/44c50385/attachment-0001.html>


More information about the mesa-dev mailing list