From: Dave Airlie <airl...@redhat.com>

This converts the Xv code to using VBOs instead of
client ptrs. This is necessary to move towards using
the core profile later.

Signed-off-by: Dave Airlie <airl...@redhat.com>
---
 glamor/glamor_xv.c | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/glamor/glamor_xv.c b/glamor/glamor_xv.c
index 85e6528..d9db574 100644
--- a/glamor/glamor_xv.c
+++ b/glamor/glamor_xv.c
@@ -245,7 +245,6 @@ glamor_xv_render(glamor_port_private *port_priv)
     PixmapPtr pixmap = port_priv->pPixmap;
     glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
     glamor_pixmap_private *src_pixmap_priv[3];
-    float vertices[32], texcoords[8];
     BoxPtr box = REGION_RECTS(&port_priv->clip);
     int nBox = REGION_NUM_RECTS(&port_priv->clip);
     int dst_x_off, dst_y_off;
@@ -260,6 +259,8 @@ glamor_xv_render(glamor_port_private *port_priv)
     float bright, cont, gamma;
     int ref = port_priv->transform_index;
     GLint uloc, sampler_loc;
+    GLfloat *v;
+    char *vbo_offset;
 
     if (!glamor_priv->xv_prog)
         glamor_init_xv_shader(screen);
@@ -335,16 +336,13 @@ glamor_xv_render(glamor_port_private *port_priv)
     sampler_loc = glGetUniformLocation(glamor_priv->xv_prog, "v_sampler");
     glUniform1i(sampler_loc, 2);
 
-    glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
-                          GL_FLOAT, GL_FALSE,
-                          2 * sizeof(float), texcoords);
+    glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
     glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
 
-    glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
-                          GL_FALSE, 2 * sizeof(float), vertices);
-
-    glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
     glEnable(GL_SCISSOR_TEST);
+
+    v = glamor_get_vbo_space(screen, 16 * sizeof(GLfloat) * nBox, &vbo_offset);
+
     for (i = 0; i < nBox; i++) {
         float off_x = box[i].x1 - port_priv->drw_x;
         float off_y = box[i].y1 - port_priv->drw_y;
@@ -352,6 +350,7 @@ glamor_xv_render(glamor_port_private *port_priv)
         float diff_y = (float) port_priv->src_h / (float) port_priv->dst_h;
         float srcx, srcy, srcw, srch;
         int dstx, dsty, dstw, dsth;
+        GLfloat *ptr = v + (i * 16);
 
         dstx = box[i].x1 + dst_x_off;
         dsty = box[i].y1 + dst_y_off;
@@ -369,7 +368,7 @@ glamor_xv_render(glamor_port_private *port_priv)
                                      dsty,
                                      dstx + dstw,
                                      dsty + dsth * 2,
-                                     vertices);
+                                     ptr);
 
         glamor_set_normalize_tcoords(src_pixmap_priv[0],
                                      src_xscale[0],
@@ -378,16 +377,28 @@ glamor_xv_render(glamor_port_private *port_priv)
                                      srcy,
                                      srcx + srcw,
                                      srcy + srch * 2,
-                                     texcoords);
+                                     ptr + 8);
+
+
+        glVertexAttribPointer(GLAMOR_VERTEX_POS, 2,
+                              GL_FLOAT, GL_FALSE,
+                              2 * sizeof(float), vbo_offset);
+
+        glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
+                              GL_FLOAT, GL_FALSE,
+                              2 * sizeof(float), vbo_offset + 8 * 
sizeof(GLfloat));
 
         glScissor(dstx, dsty, dstw, dsth);
         glDrawArrays(GL_TRIANGLE_FAN, 0, 3);
+        vbo_offset += 16 * sizeof(GLfloat);
     }
     glDisable(GL_SCISSOR_TEST);
 
     glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
     glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
 
+    glamor_put_vbo_space(screen);
+
     DamageDamageRegion(port_priv->pDraw, &port_priv->clip);
 
     glamor_xv_free_port_data(port_priv);
-- 
2.4.3

_______________________________________________
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to