summaryrefslogtreecommitdiff
path: root/glamor
diff options
context:
space:
mode:
authorGrigori Goronzy <greg@chown.ath.cx>2013-10-02 00:37:55 +0200
committerEric Anholt <eric@anholt.net>2013-12-18 11:23:54 -0800
commit8afa008ec4b393666bb3c506a711b4d50cc4e756 (patch)
treea3662a4ccaf5eccf6dd3723960a74df291c1a499 /glamor
parent229601e080aefad21927c1449cd520733317858b (diff)
Use glDrawRangeElements instead of glDrawElements
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. Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Diffstat (limited to 'glamor')
-rw-r--r--glamor/glamor_fill.c9
-rw-r--r--glamor/glamor_gl_dispatch.c1
-rw-r--r--glamor/glamor_gl_dispatch.h1
-rw-r--r--glamor/glamor_render.c6
-rw-r--r--glamor/glamor_trapezoid.c6
5 files changed, 23 insertions, 0 deletions
diff --git a/glamor/glamor_fill.c b/glamor/glamor_fill.c
index 2f08d7275..fbc87392e 100644
--- a/glamor/glamor_fill.c
+++ b/glamor/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/glamor/glamor_gl_dispatch.c b/glamor/glamor_gl_dispatch.c
index f99650425..da99e2627 100644
--- a/glamor/glamor_gl_dispatch.c
+++ b/glamor/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/glamor/glamor_gl_dispatch.h b/glamor/glamor_gl_dispatch.h
index b3fc3a629..76dadd49e 100644
--- a/glamor/glamor_gl_dispatch.h
+++ b/glamor/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/glamor/glamor_render.c b/glamor/glamor_render.c
index 27d5dc58c..d2ac38103 100644
--- a/glamor/glamor_render.c
+++ b/glamor/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/glamor/glamor_trapezoid.c b/glamor/glamor_trapezoid.c
index 7c934e346..76b3729cf 100644
--- a/glamor/glamor_trapezoid.c
+++ b/glamor/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);