summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhigang Gong <zhigang.gong@linux.intel.com>2012-06-26 15:39:24 +0800
committerZhigang Gong <zhigang.gong@linux.intel.com>2012-07-03 18:30:15 +0800
commit593bd206bf2794dc1450e8e7d20142b8d0ca074b (patch)
tree2552f1035c16bc3160f3e00a988b61ba6c8476a4
parente44ce79d719ece8997c777329834c5293fc668b8 (diff)
glamor_render: Don't allocate buffer for vbo each time.
We can reuse the last one if the last one is big enough to contain current vertext data. In the meantime, Use MapBufferRange instead of MapBuffer. Testing shows, this patch brings some benefit for aa10text/rgb10text. Not too much, but indeed faster. Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
-rw-r--r--src/glamor_render.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/glamor_render.c b/src/glamor_render.c
index 5e5ae78..b82c7c3 100644
--- a/src/glamor_render.c
+++ b/src/glamor_render.c
@@ -724,10 +724,17 @@ glamor_setup_composite_vbo(ScreenPtr screen, int n_verts)
glamor_screen_private *glamor_priv =
glamor_get_screen_private(screen);
glamor_gl_dispatch *dispatch;
+ int vert_size;
+ Bool need_new_buffer = FALSE;
glamor_priv->vbo_offset = 0;
glamor_priv->render_nr_verts = 0;
- glamor_priv->vbo_size = n_verts * sizeof(float) * 2;
+ vert_size = n_verts * sizeof(float) * 2;
+
+ if (glamor_priv->vbo_size < vert_size) {
+ glamor_priv->vbo_size = vert_size;
+ need_new_buffer = TRUE;
+ }
glamor_priv->vb_stride = 2 * sizeof(float);
if (glamor_priv->has_source_coords)
@@ -738,10 +745,14 @@ glamor_setup_composite_vbo(ScreenPtr screen, int n_verts)
dispatch = glamor_get_dispatch(glamor_priv);
dispatch->glBindBuffer(GL_ARRAY_BUFFER, glamor_priv->vbo);
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
- dispatch->glBufferData(GL_ARRAY_BUFFER,
- n_verts * sizeof(float) * 2,
- NULL, GL_DYNAMIC_DRAW);
- glamor_priv->vb = dispatch->glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
+ if (need_new_buffer)
+ dispatch->glBufferData(GL_ARRAY_BUFFER,
+ vert_size,
+ NULL, GL_DYNAMIC_DRAW);
+ glamor_priv->vb = dispatch->glMapBufferRange(GL_ARRAY_BUFFER, 0,
+ vert_size,
+ GL_MAP_READ_BIT | GL_MAP_WRITE_BIT);
+ assert(glamor_priv->vb != NULL);
}
dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glamor_priv->ebo);