[Mesa-dev] [PATCH 1/2] swrast: Fix rgba_draw_pixels with GL_COLOR_INDEX

Jason Ekstrand jason at jlekstrand.net
Mon May 4 05:53:46 PDT 2015


On May 4, 2015 6:41 AM, "Juha-Pekka Heikkila" <juhapekka.heikkila at gmail.com>
wrote:
>
> These two patches
>
> Reviewed-and-tested-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>

Those should probably be sperate tags.  Also,

Reviewed-by: Jason Ekstrand <jason.ekstrand at intel.com>

> On 04.05.2015 12:24, Iago Toral Quiroga wrote:
> > When we implemented the format conversion rewrite we forgot to handle
> > GL_COLOR_INDEX here, which needs special handling.
> >
> > Fixes the following piglit test:
> > bin/gl-1.0-drawpixels-color-index -auto -fbo
> >
> > Buzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90213
> > ---
> >  src/mesa/swrast/s_drawpix.c | 29 ++++++++++++++++++++++++++---
> >  1 file changed, 26 insertions(+), 3 deletions(-)
> >
> > diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c
> > index bf42726..fb677ee 100644
> > --- a/src/mesa/swrast/s_drawpix.c
> > +++ b/src/mesa/swrast/s_drawpix.c
> > @@ -448,14 +448,34 @@ draw_rgba_pixels( struct gl_context *ctx, GLint
x, GLint y,
> >     {
> >        const GLbitfield interpMask = span.interpMask;
> >        const GLbitfield arrayMask = span.arrayMask;
> > -      const GLint srcStride
> > -         = _mesa_image_row_stride(unpack, width, format, type);
> >        GLint skipPixels = 0;
> >        /* use span array for temp color storage */
> >        GLfloat *rgba = (GLfloat *)
span.array->attribs[VARYING_SLOT_COL0];
> >        void *tempImage = NULL;
> >
> > -      if (unpack->SwapBytes) {
> > +      /* We have to deal with GL_COLOR_INDEX manually because
> > +       * _mesa_format_convert does not handle this format. So what we
do here is
> > +       * convert it to RGBA ubyte first and then convert from that to
dst as
> > +       * usual.
> > +       */
> > +      if (format == GL_COLOR_INDEX) {
> > +         /* This will handle byte swapping and transferops if needed */
> > +         tempImage =
> > +            _mesa_unpack_color_index_to_rgba_ubyte(ctx, 2,
> > +                                                   pixels, format,
type,
> > +                                                   width, height, 1,
> > +                                                   unpack,
> > +                                                   transferOps);
> > +         if (!tempImage) {
> > +            _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels");
> > +            return;
> > +         }
> > +
> > +         transferOps = 0;
> > +         pixels = tempImage;
> > +         format = GL_RGBA;
> > +         type = GL_UNSIGNED_BYTE;
> > +      } else if (unpack->SwapBytes) {
> >           /* We have to handle byte-swapping scenarios before calling
> >            * _mesa_format_convert
> >            */
> > @@ -476,6 +496,9 @@ draw_rgba_pixels( struct gl_context *ctx, GLint x,
GLint y,
> >           }
> >        }
> >
> > +      const GLint srcStride
> > +         = _mesa_image_row_stride(unpack, width, format, type);
> > +
> >        /* if the span is wider than SWRAST_MAX_WIDTH we have to do it
in chunks */
> >        while (skipPixels < width) {
> >           const GLint spanWidth = MIN2(width - skipPixels,
SWRAST_MAX_WIDTH);
> >
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150504/b22d2486/attachment.html>


More information about the mesa-dev mailing list