[Glamor] [PATCH 1/3] Use glDrawRangeElements instead of glDrawElements

Zhigang Gong zhigang.gong at linux.intel.com
Tue Oct 8 00:49:59 PDT 2013


Pushed the whole patchset, thanks for the patchset.

On Wed, Oct 02, 2013 at 09:37:07AM -0400, Alex Deucher wrote:
> On Tue, Oct 1, 2013 at 6:37 PM, Grigori Goronzy <greg at chown.ath.cx> wrote:
> > This lets us explicitly specify the range of vertices that are used,
> > which the OpenGL driver can use for optimization. Particularly,
> > it results in lower CPU overhead with Mesa-based drivers.
> 
> For the series:
> 
> Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
> 
> > ---
> >  src/glamor_fill.c        | 9 +++++++++
> >  src/glamor_gl_dispatch.c | 1 +
> >  src/glamor_gl_dispatch.h | 1 +
> >  src/glamor_render.c      | 6 ++++++
> >  src/glamor_trapezoid.c   | 6 ++++++
> >  5 files changed, 23 insertions(+)
> >
> > diff --git a/src/glamor_fill.c b/src/glamor_fill.c
> > index 2f08d72..fbc8739 100644
> > --- a/src/glamor_fill.c
> > +++ b/src/glamor_fill.c
> > @@ -244,10 +244,19 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
> >                 if (box_cnt == 1)
> >                         dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, box_cnt * 4);
> >                 else
> > +#ifndef GLAMOR_GLES2
> > +                       dispatch->glDrawRangeElements(GL_TRIANGLES,
> > +                                                     0,
> > +                                                     box_cnt * 4,
> > +                                                     box_cnt * 6,
> > +                                                     GL_UNSIGNED_SHORT,
> > +                                                     NULL);
> > +#else
> >                         dispatch->glDrawElements(GL_TRIANGLES,
> >                                                  box_cnt * 6,
> >                                                  GL_UNSIGNED_SHORT,
> >                                                  NULL);
> > +#endif
> >                 nbox -= box_cnt;
> >                 box += box_cnt;
> >         }
> > diff --git a/src/glamor_gl_dispatch.c b/src/glamor_gl_dispatch.c
> > index f996504..da99e26 100644
> > --- a/src/glamor_gl_dispatch.c
> > +++ b/src/glamor_gl_dispatch.c
> > @@ -54,6 +54,7 @@ glamor_gl_dispatch_init_impl(struct glamor_gl_dispatch *dispatch,
> >         INIT_FUNC(dispatch, glMapBufferRange, get_proc_address);
> >         INIT_FUNC(dispatch, glUnmapBuffer, get_proc_address);
> >         INIT_FUNC(dispatch, glBlitFramebuffer, get_proc_address);
> > +       INIT_FUNC(dispatch, glDrawRangeElements, get_proc_address);
> >  #endif
> >         INIT_FUNC(dispatch, glViewport, get_proc_address);
> >         INIT_FUNC(dispatch, glDrawArrays, get_proc_address);
> > diff --git a/src/glamor_gl_dispatch.h b/src/glamor_gl_dispatch.h
> > index b3fc3a6..76dadd4 100644
> > --- a/src/glamor_gl_dispatch.h
> > +++ b/src/glamor_gl_dispatch.h
> > @@ -12,6 +12,7 @@ typedef struct glamor_gl_dispatch {
> >
> >         /* Elements Array*/
> >         void (*glDrawElements) (GLenum mode, GLsizei count, GLenum type, const GLvoid * indices);
> > +       void (*glDrawRangeElements) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid * indices);
> >
> >         /* Raster functions */
> >         void (*glReadPixels) (GLint x, GLint y,
> > diff --git a/src/glamor_render.c b/src/glamor_render.c
> > index 27d5dc5..d2ac381 100644
> > --- a/src/glamor_render.c
> > +++ b/src/glamor_render.c
> > @@ -841,8 +841,14 @@ glamor_flush_composite_rects(ScreenPtr screen)
> >         if (!glamor_priv->render_nr_verts)
> >                 return;
> >
> > +#ifndef GLAMOR_GLES2
> > +       dispatch->glDrawRangeElements(GL_TRIANGLES, 0, glamor_priv->render_nr_verts,
> > +                                     (glamor_priv->render_nr_verts * 3) / 2,
> > +                                     GL_UNSIGNED_SHORT, NULL);
> > +#else
> >         dispatch->glDrawElements(GL_TRIANGLES, (glamor_priv->render_nr_verts * 3) / 2,
> >                                  GL_UNSIGNED_SHORT, NULL);
> > +#endif
> >         glamor_put_dispatch(glamor_priv);
> >  }
> >
> > diff --git a/src/glamor_trapezoid.c b/src/glamor_trapezoid.c
> > index 7c934e3..76b3729 100644
> > --- a/src/glamor_trapezoid.c
> > +++ b/src/glamor_trapezoid.c
> > @@ -1543,8 +1543,14 @@ _glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture,
> >                                 glamor_priv->vb, GL_DYNAMIC_DRAW);
> >                 }
> >
> > +#ifndef GLAMOR_GLES2
> > +               dispatch->glDrawRangeElements(GL_TRIANGLES, 0, glamor_priv->render_nr_verts,
> > +                       (glamor_priv->render_nr_verts * 3) / 2,
> > +                       GL_UNSIGNED_SHORT, NULL);
> > +#else
> >                 dispatch->glDrawElements(GL_TRIANGLES, (glamor_priv->render_nr_verts * 3) / 2,
> >                         GL_UNSIGNED_SHORT, NULL);
> > +#endif
> >         }
> >
> >         dispatch->glBindBuffer(GL_ARRAY_BUFFER, 0);
> > --
> > 1.8.1.2
> >
> > _______________________________________________
> > Glamor mailing list
> > Glamor at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/glamor
> _______________________________________________
> Glamor mailing list
> Glamor at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/glamor


More information about the Glamor mailing list