[Mesa-dev] [PATCH 1/6] mesa: Add _mesa_format_fallback_rgba_to_rgbx()

Chad Versace chadversary at chromium.org
Tue Jun 6 22:11:18 UTC 2017


On Tue 06 Jun 2017, Dylan Baker wrote:
> Quoting Chad Versace (2017-06-06 13:36:55)
> > The new function takes a mesa_format and, if the format is an alpha
> > format with a non-alpha variant, returns the non-alpha format.
> > Otherwise, it returns the original format.
> > 
> > Example:
> >   input -> output
> > 
> >   // Fallback exists
> >   MESA_FORMAT_R8G8B8X8_UNORM -> MESA_FORMAT_R8G8B8A8_UNORM
> >   MESA_FORMAT_RGBX_UNORM16 -> MESA_FORMAT_RGBA_UNORM16
> > 
> >   // No fallback
> >   MESA_FORMAT_R8G8B8A8_UNORM -> MESA_FORMAT_R8G8B8A8_UNORM
> >   MESA_FORMAT_Z_FLOAT32 -> MESA_FORMAT_Z_FLOAT32
> > 
> > i965 will use this for EGLImages and DRIimages.
> > ---
> >  src/mesa/Android.gen.mk          |  12 +++
> >  src/mesa/Makefile.am             |   7 ++
> >  src/mesa/Makefile.sources        |   2 +
> >  src/mesa/main/.gitignore         |   1 +
> >  src/mesa/main/format_fallback.h  |  31 +++++++
> >  src/mesa/main/format_fallback.py | 180 +++++++++++++++++++++++++++++++++++++++
> >  6 files changed, 233 insertions(+)
> >  create mode 100644 src/mesa/main/format_fallback.h
> >  create mode 100644 src/mesa/main/format_fallback.py

[snip]

> > +def main():
> > +    pargs = parse_args()
> > +
> > +    formats = {}
> > +    for fmt in format_parser.parse(pargs.csv):
> > +        formats[fmt.name] = fmt
> 
> You could simplify this as:
> formats = {f.name: f for f in format_parser.parse(pargs.csv)}

Thanks. I'll do that.

> 
> > +
> > +    write_preamble(stdout)
> > +    write_func_mesa_format_fallback_rgbx_to_rgba(stdout, formats)
> 
> We really shouldn't write to stdout like this, it can cause all kinds of
> breakages if there's ever a UTF-8 character (say ©) and the terminal doesn't
> have a unicode locale it'll fail,

Ugh. I wasn't aware that Python's stdout was broken. Is Python's
sys.stdout opened in "text" mode, and is that the cause of the
brokenness?

Does it still fail if stdout is redirected to a file? Because that's the
only case that matters here.

> if you just open the file you want (say one
> passed as an argument) then it doesn't matter what the console supports. We do
> this all over the place so it's not a blocker for me, but I still think it's a
> bad idea to write to stdout.

> If you decide not to change this you at the very least need to call
> stdout.flush() after write_func_mesa_format_fallback_Rgbx_to_rgba.


More information about the mesa-dev mailing list