xserver: Branch 'master' - 19 commits

Keith Packard keithp at kemper.freedesktop.org
Wed Mar 26 22:12:01 PDT 2014


 dix/gc.c                    |    8 
 glamor/Makefile.am          |    5 
 glamor/glamor.c             |   32 ++-
 glamor/glamor.h             |    7 
 glamor/glamor_core.c        |   45 -----
 glamor/glamor_fbo.c         |    3 
 glamor/glamor_fill.c        |    3 
 glamor/glamor_glyphs.c      |    2 
 glamor/glamor_gradient.c    |   60 ------
 glamor/glamor_largepixmap.c |   10 -
 glamor/glamor_pixmap.c      |   14 -
 glamor/glamor_points.c      |  129 ++++++++++++++
 glamor/glamor_polyops.c     |   82 ---------
 glamor/glamor_priv.h        |   65 +++++--
 glamor/glamor_program.c     |  394 ++++++++++++++++++++++++++++++++++++++++++++
 glamor/glamor_program.h     |   94 ++++++++++
 glamor/glamor_render.c      |   29 ---
 glamor/glamor_segment.c     |   39 ++++
 glamor/glamor_transform.c   |  215 ++++++++++++++++++++++++
 glamor/glamor_transform.h   |   87 +++++++++
 glamor/glamor_trapezoid.c   |    6 
 glamor/glamor_vbo.c         |    6 
 hw/kdrive/ephyr/Makefile.am |    2 
 hw/kdrive/ephyr/hostx.c     |    4 
 hw/kdrive/src/kxv.c         |   27 ---
 hw/kdrive/src/kxv.h         |   36 ----
 hw/xfree86/Makefile.am      |    2 
 mi/mibitblt.c               |    2 
 28 files changed, 1080 insertions(+), 328 deletions(-)

New commits:
commit 1b5d7e78460ed686ba2da398dab341d4867fd4a0
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Mar 12 14:35:27 2014 -0700

    glamor: Add glamor_program PolyPoint implementation
    
    This accelerates poly point when possible by off-loading all geometry
    computation to the GPU.
    
    Improves x11perf -dot performance by 28109.5% +/- 1022.01% (n=3)
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Eric Anholt <eric at anholt.net>

diff --git a/glamor/Makefile.am b/glamor/Makefile.am
index eff769e..8555e40 100644
--- a/glamor/Makefile.am
+++ b/glamor/Makefile.am
@@ -32,7 +32,7 @@ libglamor_la_SOURCES = \
 	glamor_getimage.c\
 	glamor_copyplane.c\
 	glamor_glyphblt.c\
-	glamor_polyops.c\
+	glamor_points.c\
 	glamor_priv.h\
 	glamor_pixmap.c\
 	glamor_largepixmap.c\
diff --git a/glamor/glamor_points.c b/glamor/glamor_points.c
new file mode 100644
index 0000000..5399f96
--- /dev/null
+++ b/glamor/glamor_points.c
@@ -0,0 +1,129 @@
+/*
+ * Copyright © 2009 Intel Corporation
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Zhigang Gong <zhigang.gong at linux.intel.com>
+ *
+ */
+
+#include "glamor_priv.h"
+#include "glamor_transform.h"
+
+static const glamor_facet glamor_facet_point = {
+    .name = "poly_point",
+    .vs_vars = "attribute vec2 primitive;\n",
+    .vs_exec = GLAMOR_POS(gl_Position, primitive),
+};
+
+Bool
+glamor_poly_point_nf(DrawablePtr drawable, GCPtr gc, int mode, int npt, DDXPointPtr ppt)
+{
+    ScreenPtr screen = drawable->pScreen;
+    glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+    PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
+    glamor_program *prog = &glamor_priv->point_prog;
+    glamor_pixmap_private *pixmap_priv;
+    int off_x, off_y;
+    GLshort *vbo_ppt;
+    char *vbo_offset;
+    int box_x, box_y;
+
+    pixmap_priv = glamor_get_pixmap_private(pixmap);
+    if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
+        goto bail;
+
+    glamor_get_context(glamor_priv);
+
+    if (prog->failed)
+        goto bail_ctx;
+
+    if (!prog->prog) {
+        if (!glamor_build_program(screen, prog,
+                                  &glamor_facet_point,
+                                  &glamor_fill_solid))
+            goto bail_ctx;
+    }
+
+    if (!glamor_use_program(pixmap, gc, prog, NULL))
+        goto bail_ctx;
+
+    vbo_ppt = glamor_get_vbo_space(screen, npt * (2 * sizeof (INT16)), &vbo_offset);
+    glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+    glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_SHORT, GL_FALSE, 0, vbo_offset);
+    if (mode == CoordModePrevious) {
+        int n = npt;
+        INT16 x = 0, y = 0;
+        while (n--) {
+            vbo_ppt[0] = (x += ppt->x);
+            vbo_ppt[1] = (y += ppt->y);
+            vbo_ppt += 2;
+            ppt++;
+        }
+    } else
+        memcpy(vbo_ppt, ppt, npt * (2 * sizeof (INT16)));
+    glamor_put_vbo_space(screen);
+
+    glEnable(GL_SCISSOR_TEST);
+
+    glamor_pixmap_loop(pixmap_priv, box_x, box_y) {
+        int nbox = RegionNumRects(gc->pCompositeClip);
+        BoxPtr box = RegionRects(gc->pCompositeClip);
+
+        glamor_set_destination_drawable(drawable, box_x, box_y, TRUE, TRUE, prog->matrix_uniform, &off_x, &off_y);
+
+        while (nbox--) {
+            glScissor(box->x1 + off_x,
+                      box->y1 + off_y,
+                      box->x2 - box->x1,
+                      box->y2 - box->y1);
+            box++;
+            glDrawArrays(GL_POINTS, 0, npt);
+        }
+    }
+
+    glDisable(GL_SCISSOR_TEST);
+    glDisable(GL_COLOR_LOGIC_OP);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+
+    glamor_put_context(glamor_priv);
+
+    glamor_priv->state = RENDER_STATE;
+    glamor_priv->render_idle_cnt = 0;
+
+    return TRUE;
+
+bail_ctx:
+    glDisable(GL_COLOR_LOGIC_OP);
+    glamor_put_context(glamor_priv);
+bail:
+    return FALSE;
+}
+
+void
+glamor_poly_point(DrawablePtr drawable, GCPtr gc, int mode, int npt,
+                  DDXPointPtr ppt)
+{
+    if (glamor_poly_point_nf(drawable, gc, mode, npt, ppt))
+        return;
+    miPolyPoint(drawable, gc, mode, npt, ppt);
+}
diff --git a/glamor/glamor_polyops.c b/glamor/glamor_polyops.c
deleted file mode 100644
index f4036a0..0000000
--- a/glamor/glamor_polyops.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright © 2009 Intel Corporation
- * Copyright © 1998 Keith Packard
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- *
- * Authors:
- *    Zhigang Gong <zhigang.gong at linux.intel.com>
- *
- */
-
-#include "glamor_priv.h"
-
-static Bool
-_glamor_poly_point(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
-                   DDXPointPtr ppt, Bool fallback)
-{
-    if (!fallback && glamor_ddx_fallback_check_gc(pGC)
-        && glamor_ddx_fallback_check_pixmap(pDrawable))
-        return FALSE;
-
-    miPolyPoint(pDrawable, pGC, mode, npt, ppt);
-
-    return TRUE;
-}
-
-void
-glamor_poly_point(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
-                  DDXPointPtr ppt)
-{
-    _glamor_poly_point(pDrawable, pGC, mode, npt, ppt, TRUE);
-}
-
-Bool
-glamor_poly_point_nf(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
-                     DDXPointPtr ppt)
-{
-    return _glamor_poly_point(pDrawable, pGC, mode, npt, ppt, FALSE);
-}
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 164d581..4c305ab 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -220,6 +220,9 @@ typedef struct glamor_screen_private {
     GLint solid_prog;
     GLint solid_color_uniform_location;
 
+    /* glamor point shader */
+    glamor_program point_prog;
+
     /* vertext/elment_index buffer object for render */
     GLuint vbo, ebo;
     /** Next offset within the VBO that glamor_get_vbo_space() will use. */
commit 72a4beff6d3aed767df9a30bca0c1d860715928f
Author: Keith Packard <keithp at keithp.com>
Date:   Sat Mar 22 15:20:49 2014 -0700

    glamor: Move glamor_poly_segment to separate glamor_segment.c file
    
    There's no reason to mix PolyPoint and PolySegment in the same file.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-off-by: Eric Anholt <eric at anholt.net>

diff --git a/glamor/Makefile.am b/glamor/Makefile.am
index dec6467..eff769e 100644
--- a/glamor/Makefile.am
+++ b/glamor/Makefile.am
@@ -20,6 +20,7 @@ libglamor_la_SOURCES = \
 	glamor_polylines.c \
 	glamor_putimage.c \
 	glamor_setspans.c \
+	glamor_segment.c \
 	glamor_render.c \
 	glamor_gradient.c \
 	glamor_program.c \
diff --git a/glamor/glamor_polyops.c b/glamor/glamor_polyops.c
index 1484d80..f4036a0 100644
--- a/glamor/glamor_polyops.c
+++ b/glamor/glamor_polyops.c
@@ -54,29 +54,3 @@ glamor_poly_point_nf(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
 {
     return _glamor_poly_point(pDrawable, pGC, mode, npt, ppt, FALSE);
 }
-
-static Bool
-_glamor_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg,
-                     xSegment *pSeg, Bool fallback)
-{
-    if (!fallback && glamor_ddx_fallback_check_gc(pGC)
-        && glamor_ddx_fallback_check_pixmap(pDrawable))
-        return FALSE;
-
-    miPolySegment(pDrawable, pGC, nseg, pSeg);
-
-    return TRUE;
-}
-
-void
-glamor_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment *pSeg)
-{
-    _glamor_poly_segment(pDrawable, pGC, nseg, pSeg, TRUE);
-}
-
-Bool
-glamor_poly_segment_nf(DrawablePtr pDrawable, GCPtr pGC, int nseg,
-                       xSegment *pSeg)
-{
-    return _glamor_poly_segment(pDrawable, pGC, nseg, pSeg, FALSE);
-}
diff --git a/glamor/glamor_segment.c b/glamor/glamor_segment.c
new file mode 100644
index 0000000..84b27ac
--- /dev/null
+++ b/glamor/glamor_segment.c
@@ -0,0 +1,39 @@
+/*
+ * Copyright © 2014 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include "glamor_priv.h"
+
+Bool
+glamor_poly_segment_nf(DrawablePtr drawable, GCPtr gc, int nseg,
+                       xSegment *seg)
+{
+    return FALSE;
+}
+
+void
+glamor_poly_segment(DrawablePtr drawable, GCPtr gc, int nseg,
+                    xSegment *seg)
+{
+    if (glamor_poly_segment_nf(drawable, gc, nseg, seg))
+        return;
+    miPolySegment(drawable, gc, nseg, seg);
+}
commit 029b64c30a8bdf87edfdb1c988f4e8dcee1bb4ef
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Mar 12 14:27:59 2014 -0700

    glamor: Add infrastructure for generating shaders on the fly
    
    This just adds a bunch of support code to construct shaders from
    'facets', which bundle attributes needed for each layer of the
    rendering system. At this point, that includes only the primitive and
    the fill stuff.
    
    v2: Correct comment in glamor transform about 1/2 pixel correction needed
        for GL_POINT. (Eric Anholt)
    v3: Rebase on Markus's cleanups (change by anholt)
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Eric Anholt <eric at anholt.net>

diff --git a/glamor/Makefile.am b/glamor/Makefile.am
index ffc8c23..dec6467 100644
--- a/glamor/Makefile.am
+++ b/glamor/Makefile.am
@@ -22,6 +22,8 @@ libglamor_la_SOURCES = \
 	glamor_setspans.c \
 	glamor_render.c \
 	glamor_gradient.c \
+	glamor_program.c \
+	glamor_transform.c \
 	glamor_trapezoid.c \
 	glamor_tile.c \
 	glamor_triangles.c\
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index ed2c767..164d581 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -52,6 +52,7 @@
 
 #include "glamor_debug.h"
 #include "glamor_context.h"
+#include "glamor_program.h"
 
 #include <list.h>
 
diff --git a/glamor/glamor_program.c b/glamor/glamor_program.c
new file mode 100644
index 0000000..e2e1434
--- /dev/null
+++ b/glamor/glamor_program.c
@@ -0,0 +1,394 @@
+/*
+ * Copyright © 2014 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include "glamor_priv.h"
+#include "glamor_transform.h"
+#include "glamor_program.h"
+
+static Bool
+use_solid(PixmapPtr pixmap, GCPtr gc, glamor_program *prog, void *arg)
+{
+    return glamor_set_solid(pixmap, gc, TRUE, prog->fg_uniform);
+}
+
+const glamor_facet glamor_fill_solid = {
+    .name = "solid",
+    .fs_exec = "       gl_FragColor = fg;\n",
+    .locations = glamor_program_location_fg,
+    .use = use_solid,
+};
+
+static Bool
+use_tile(PixmapPtr pixmap, GCPtr gc, glamor_program *prog, void *arg)
+{
+    return glamor_set_tiled(pixmap, gc, prog->fill_offset_uniform, prog->fill_size_uniform);
+}
+
+static const glamor_facet glamor_fill_tile = {
+    .name = "tile",
+    .version = 130,
+    .vs_exec =  "       fill_pos = fill_offset + primitive.xy + pos;\n",
+    .fs_exec =  "       gl_FragColor = texelFetch(sampler, ivec2(mod(fill_pos,fill_size)), 0);\n",
+    .locations = glamor_program_location_fill,
+    .use = use_tile,
+};
+
+#if 0
+static Bool
+use_stipple(PixmapPtr pixmap, GCPtr gc, glamor_program *prog)
+{
+    return glamor_set_stippled(pixmap, gc, prog->fg_uniform, prog->fill_offset_uniform, prog->fill_size_uniform);
+}
+
+static const glamor_facet glamor_fill_stipple = {
+    .name = "stipple",
+    .version = 130,
+    .vs_exec =  "       fill_pos = fill_offset + primitive.xy + pos;\n";
+    .fs_exec = ("       if (texelFetch(sampler, ivec2(mod(fill_pos,fill_size)), 0).x == 0)\n"
+                "               discard;\n"
+                "       gl_FragColor = fg;\n")
+    .locations = glamor_program_location_fg | glamor_program_location_fill
+    .use = use_stipple,
+};
+
+static const glamor_facet glamor_fill_opaque_stipple = {
+    .name = "opaque_stipple",
+    .version = 130,
+    .vs_exec =  "       fill_pos = fill_offset + primitive.xy + pos;\n";
+    .fs_exec = ("       if (texelFetch(sampler, ivec2(mod(fill_pos,fill_size)), 0).x == 0)\n"
+                "               gl_FragColor = bg;\n"
+                "       else\n"
+                "               gl_FragColor = fg;\n"),
+    .locations = glamor_program_location_fg | glamor_program_location_bg | glamor_program_location_fill
+    .use = use_opaque_stipple
+};
+#endif
+
+static const glamor_facet *glamor_facet_fill[4] = {
+    &glamor_fill_solid,
+    &glamor_fill_tile,
+    NULL,
+    NULL,
+};
+
+typedef struct {
+    glamor_program_location     location;
+    const char                  *vs_vars;
+    const char                  *fs_vars;
+} glamor_location_var;
+
+static glamor_location_var location_vars[] = {
+    {
+        .location = glamor_program_location_fg,
+        .fs_vars = "uniform vec4 fg;\n"
+    },
+    {
+        .location = glamor_program_location_bg,
+        .fs_vars = "uniform vec4 bg;\n"
+    },
+    {
+        .location = glamor_program_location_fill,
+        .vs_vars = ("uniform vec2 fill_offset;\n"
+                    "varying vec2 fill_pos;\n"),
+        .fs_vars = ("uniform sampler2D sampler;\n"
+                    "uniform vec2 fill_size;\n"
+                    "varying vec2 fill_pos;\n")
+    },
+    {
+        .location = glamor_program_location_font,
+        .fs_vars = "uniform usampler2D font;\n",
+    },
+};
+
+#define NUM_LOCATION_VARS       (sizeof location_vars / sizeof location_vars[0])
+
+static char *
+add_var(char *cur, const char *add)
+{
+    char *new;
+
+    if (!add)
+        return cur;
+
+    new = realloc(cur, strlen(cur) + strlen(add) + 1);
+    if (!new) {
+        free(cur);
+        return NULL;
+    }
+    strcat(new, add);
+    return new;
+}
+
+static char *
+vs_location_vars(glamor_program_location locations)
+{
+    int l;
+    char *vars = strdup("");
+
+    for (l = 0; vars && l < NUM_LOCATION_VARS; l++)
+        if (locations & location_vars[l].location)
+            vars = add_var(vars, location_vars[l].vs_vars);
+    return vars;
+}
+
+static char *
+fs_location_vars(glamor_program_location locations)
+{
+    int l;
+    char *vars = strdup("");
+
+    for (l = 0; vars && l < NUM_LOCATION_VARS; l++)
+        if (locations & location_vars[l].location)
+            vars = add_var(vars, location_vars[l].fs_vars);
+    return vars;
+}
+
+static const char vs_template[] =
+    "%s"                                /* version */
+    "%s"                                /* prim vs_vars */
+    "%s"                                /* fill vs_vars */
+    "%s"                                /* location vs_vars */
+    GLAMOR_DECLARE_MATRIX
+    "void main() {\n"
+    "%s"                                /* prim vs_exec, outputs 'pos' and gl_Position */
+    "%s"                                /* fill vs_exec */
+    "}\n";
+
+static const char fs_template[] =
+    "%s"                                /* version */
+    GLAMOR_DEFAULT_PRECISION
+    "%s"                                /* prim fs_vars */
+    "%s"                                /* fill fs_vars */
+    "%s"                                /* location fs_vars */
+    "void main() {\n"
+    "%s"                                /* prim fs_exec */
+    "%s"                                /* fill fs_exec */
+    "}\n";
+
+static const char *
+str(const char *s)
+{
+    if (!s)
+        return "";
+    return s;
+}
+
+static const glamor_facet facet_null_fill = {
+    .name = ""
+};
+
+static GLint
+glamor_get_uniform(glamor_program               *prog,
+                   glamor_program_location      location,
+                   const char                   *name)
+{
+    GLint uniform;
+    if (location && (prog->locations & location) == 0)
+        return -2;
+    uniform = glGetUniformLocation(prog->prog, name);
+#if DBG
+    ErrorF("%s uniform %d\n", name, uniform);
+#endif
+    return uniform;
+}
+
+Bool
+glamor_build_program(ScreenPtr          screen,
+                     glamor_program     *prog,
+                     const glamor_facet *prim,
+                     const glamor_facet *fill)
+{
+    glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+
+    glamor_program_location     locations = prim->locations;
+    glamor_program_flag         flags = prim->flags;
+
+    int                         version = prim->version;
+    char                        *version_string = NULL;
+
+    char                        *fs_vars = NULL;
+    char                        *vs_vars = NULL;
+
+    char                        *vs_prog_string;
+    char                        *fs_prog_string;
+
+    GLint                       fs_prog, vs_prog;
+
+    if (!fill)
+        fill = &facet_null_fill;
+
+    locations |= fill->locations;
+    flags |= fill->flags;
+    version = MAX(version, fill->version);
+
+    if (version >= 130) {
+
+        /* Would be nice to have a cleaner test for GLSL 1.30 support,
+         * but for now this should suffice
+         */
+        if (glamor_priv->gl_flavor != GLAMOR_GL_DESKTOP ||
+            epoxy_gl_version() < 30) {
+            goto fail;
+        }
+    }
+
+    vs_vars = vs_location_vars(locations);
+    fs_vars = fs_location_vars(locations);
+
+    if (!vs_vars)
+        goto fail;
+    if (!fs_vars)
+        goto fail;
+
+    if (version) {
+        if (asprintf(&version_string, "#version %d\n", version) < 0)
+            version_string = NULL;
+        if (!version_string)
+            goto fail;
+    }
+
+    if (asprintf(&vs_prog_string,
+                 vs_template,
+                 str(version_string),
+                 str(prim->vs_vars),
+                 str(fill->vs_vars),
+                 vs_vars,
+                 str(prim->vs_exec),
+                 str(fill->vs_exec)) < 0)
+        vs_prog_string = NULL;
+
+    if (asprintf(&fs_prog_string,
+                 fs_template,
+                 str(version_string),
+                 str(prim->fs_vars),
+                 str(fill->fs_vars),
+                 fs_vars,
+                 str(prim->fs_exec),
+                 str(fill->fs_exec)) < 0)
+        fs_prog_string = NULL;
+
+    if (!vs_prog_string || !fs_prog_string)
+        goto fail;
+
+#define DBG 0
+#if DBG
+    ErrorF("\nPrograms for %s %s\nVertex shader:\n\n%s\n\nFragment Shader:\n\n%s",
+           prim->name, fill->name, vs_prog_string, fs_prog_string);
+#endif
+
+    prog->prog = glCreateProgram();
+    prog->flags = flags;
+    prog->locations = locations;
+    prog->prim_use = prim->use;
+    prog->fill_use = fill->use;
+
+    vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, vs_prog_string);
+    fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, fs_prog_string);
+    free(vs_prog_string);
+    free(fs_prog_string);
+    glAttachShader(prog->prog, vs_prog);
+    glDeleteShader(vs_prog);
+    glAttachShader(prog->prog, fs_prog);
+    glDeleteShader(fs_prog);
+    glBindAttribLocation(prog->prog, GLAMOR_VERTEX_POS, "primitive");
+
+    if (prim->source_name) {
+#if DBG
+        ErrorF("Bind GLAMOR_VERTEX_SOURCE to %s\n", prim->source_name);
+#endif
+        glBindAttribLocation(prog->prog, GLAMOR_VERTEX_SOURCE, prim->source_name);
+    }
+
+    glamor_link_glsl_prog(screen, prog->prog, "%s_%s", prim->name, fill->name);
+
+    prog->matrix_uniform = glamor_get_uniform(prog, glamor_program_location_none, "v_matrix");
+    prog->fg_uniform = glamor_get_uniform(prog, glamor_program_location_fg, "fg");
+    prog->bg_uniform = glamor_get_uniform(prog, glamor_program_location_bg, "bg");
+    prog->fill_offset_uniform = glamor_get_uniform(prog, glamor_program_location_fill, "fill_offset");
+    prog->fill_size_uniform = glamor_get_uniform(prog, glamor_program_location_fill, "fill_size");
+    prog->font_uniform = glamor_get_uniform(prog, glamor_program_location_font, "font");
+
+    if (glGetError() != GL_NO_ERROR)
+        goto fail;
+
+    free(version_string);
+    free(fs_vars);
+    free(vs_vars);
+    return TRUE;
+fail:
+    prog->failed = 1;
+    if (prog->prog) {
+        glDeleteProgram(prog->prog);
+        prog->prog = 0;
+    }
+    free(version_string);
+    free(fs_vars);
+    free(vs_vars);
+    return FALSE;
+}
+
+Bool
+glamor_use_program(PixmapPtr            pixmap,
+                   GCPtr                gc,
+                   glamor_program       *prog,
+                   void                 *arg)
+{
+    glUseProgram(prog->prog);
+
+    if (prog->prim_use && !prog->prim_use(pixmap, gc, prog, arg))
+        return FALSE;
+
+    if (prog->fill_use && !prog->fill_use(pixmap, gc, prog, arg))
+        return FALSE;
+
+    return TRUE;
+}
+
+glamor_program *
+glamor_use_program_fill(PixmapPtr               pixmap,
+                        GCPtr                   gc,
+                        glamor_program_fill     *program_fill,
+                        const glamor_facet      *prim)
+{
+    ScreenPtr                   screen = pixmap->drawable.pScreen;
+    glamor_program              *prog = &program_fill->progs[gc->fillStyle];
+
+    int                         fill_style = gc->fillStyle;
+    const glamor_facet          *fill;
+
+    if (prog->failed)
+        return FALSE;
+
+    if (!prog->prog) {
+        fill = glamor_facet_fill[fill_style];
+        if (!fill)
+            return NULL;
+
+        if (!glamor_build_program(screen, prog, prim, fill))
+            return NULL;
+    }
+
+    if (!glamor_use_program(pixmap, gc, prog, NULL))
+        return NULL;
+
+    return prog;
+}
diff --git a/glamor/glamor_program.h b/glamor/glamor_program.h
new file mode 100644
index 0000000..88efc35
--- /dev/null
+++ b/glamor/glamor_program.h
@@ -0,0 +1,94 @@
+/*
+ * Copyright © 2014 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#ifndef _GLAMOR_PROGRAM_H_
+#define _GLAMOR_PROGRAM_H_
+
+typedef enum {
+    glamor_program_location_none = 0,
+    glamor_program_location_fg = 1,
+    glamor_program_location_bg = 2,
+    glamor_program_location_fill = 4,
+    glamor_program_location_font = 8,
+} glamor_program_location;
+
+typedef enum {
+    glamor_program_flag_none = 0,
+} glamor_program_flag;
+
+typedef struct _glamor_program glamor_program;
+
+typedef Bool (*glamor_use) (PixmapPtr pixmap, GCPtr gc, glamor_program *prog, void *arg);
+
+typedef struct {
+    const char                          *name;
+    const int                           version;
+    const char                          *vs_vars;
+    const char                          *vs_exec;
+    const char                          *fs_vars;
+    const char                          *fs_exec;
+    const glamor_program_location       locations;
+    const glamor_program_flag           flags;
+    const char                          *source_name;
+    glamor_use                          use;
+} glamor_facet;
+
+struct _glamor_program {
+    GLint                       prog;
+    GLint                       failed;
+    GLint                       matrix_uniform;
+    GLint                       fg_uniform;
+    GLint                       bg_uniform;
+    GLint                       fill_size_uniform;
+    GLint                       fill_offset_uniform;
+    GLint                       font_uniform;
+    glamor_program_location     locations;
+    glamor_program_flag         flags;
+    glamor_use                  prim_use;
+    glamor_use                  fill_use;
+};
+
+typedef struct {
+    glamor_program      progs[4];
+} glamor_program_fill;
+
+extern const glamor_facet glamor_fill_solid;
+
+Bool
+glamor_build_program(ScreenPtr          screen,
+                     glamor_program     *prog,
+                     const glamor_facet *prim,
+                     const glamor_facet *fill);
+
+Bool
+glamor_use_program(PixmapPtr            pixmap,
+                   GCPtr                gc,
+                   glamor_program       *prog,
+                   void                 *arg);
+
+glamor_program *
+glamor_use_program_fill(PixmapPtr               pixmap,
+                        GCPtr                   gc,
+                        glamor_program_fill     *program_fill,
+                        const glamor_facet      *prim);
+
+#endif /* _GLAMOR_PROGRAM_H_ */
diff --git a/glamor/glamor_transform.c b/glamor/glamor_transform.c
new file mode 100644
index 0000000..d6ba564
--- /dev/null
+++ b/glamor/glamor_transform.c
@@ -0,0 +1,215 @@
+/*
+ * Copyright © 2014 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include "glamor_priv.h"
+#include "glamor_transform.h"
+
+
+/*
+ * Set up rendering to target the specified drawable, computing an
+ * appropriate transform for the vertex shader to convert
+ * drawable-relative coordinates into pixmap-relative coordinates. If
+ * requested, the offset from pixmap origin coordinates back to window
+ * system coordinates will be returned in *p_off_x, *p_off_y so that
+ * clipping computations can be adjusted as appropriate
+ */
+
+void
+glamor_set_destination_drawable(DrawablePtr     drawable,
+                                int             box_x,
+                                int             box_y,
+                                Bool            do_drawable_translate,
+                                Bool            center_offset,
+                                GLint           matrix_uniform_location,
+                                int             *p_off_x,
+                                int             *p_off_y)
+{
+    PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
+    glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
+    int off_x, off_y;
+    BoxPtr box = glamor_pixmap_box_at(pixmap_priv, box_x, box_y);
+    int w = box->x2 - box->x1;
+    int h = box->y2 - box->y1;
+    float scale_x = 2.0f / (float) w;
+    float scale_y = 2.0f / (float) h;
+    float center_adjust = 0.0f;
+
+    glamor_get_drawable_deltas(drawable, pixmap, &off_x, &off_y);
+
+    off_x -= box->x1;
+    off_y -= box->y1;
+
+    if (p_off_x) {
+        *p_off_x = off_x;
+        *p_off_y = off_y;
+    }
+
+    /* A tricky computation to find the right value for the two linear functions
+     * that transform rendering coordinates to pixmap coordinates
+     *
+     *  pixmap_x = render_x + drawable->x + off_x
+     *  pixmap_y = render_y + drawable->y + off_y
+     *
+     *  gl_x = pixmap_x * 2 / width - 1
+     *  gl_y = pixmap_y * 2 / height - 1
+     *
+     *  gl_x = (render_x + drawable->x + off_x) * 2 / width - 1
+     *
+     *  gl_x = (render_x) * 2 / width + (drawable->x + off_x) * 2 / width - 1
+     *
+     * I'll think about yInverted later, when I have some way to test
+     */
+
+    if (do_drawable_translate) {
+        off_x += drawable->x;
+        off_y += drawable->y;
+    }
+
+    /*
+     * To get GL_POINTS drawn in the right spot, we need to adjust the
+     * coordinates by 1/2 a pixel.
+     */
+    if (center_offset)
+        center_adjust = 0.5f;
+
+    glUniform4f(matrix_uniform_location,
+                scale_x, (off_x + center_adjust) * scale_x - 1.0f,
+                scale_y, (off_y + center_adjust) * scale_y - 1.0f);
+
+    glamor_set_destination_pixmap_fbo(glamor_pixmap_fbo_at(pixmap_priv, box_x, box_y),
+                                      0, 0, w, h);
+}
+
+/*
+ * Set up for solid rendering to the specified pixmap using alu, fg and planemask
+ * from the specified GC. Load the target color into the specified uniform
+ */
+
+void
+glamor_set_color(PixmapPtr      pixmap,
+                 CARD32         pixel,
+                 GLint          uniform)
+{
+    float       color[4];
+
+    glamor_get_rgba_from_pixel(pixel,
+                               &color[0], &color[1], &color[2], &color[3],
+                               format_for_pixmap(pixmap));
+
+    glUniform4fv(uniform, 1, color);
+}
+
+Bool
+glamor_set_solid(PixmapPtr      pixmap,
+                 GCPtr          gc,
+                 Bool           use_alu,
+                 GLint          uniform)
+{
+    CARD32      pixel;
+    int         alu = use_alu ? gc->alu : GXcopy;
+
+    if (!glamor_set_planemask(pixmap, gc->planemask))
+        return FALSE;
+
+    pixel = gc->fgPixel;
+
+    if (!glamor_set_alu(pixmap->drawable.pScreen, alu)) {
+        switch (gc->alu) {
+        case GXclear:
+            pixel = 0;
+            break;
+        case GXcopyInverted:
+            pixel = ~pixel;
+            break;
+        case GXset:
+            pixel = ~0 & gc->planemask;
+            break;
+        default:
+            return FALSE;
+        }
+    }
+    glamor_set_color(pixmap, gc->fgPixel, uniform);
+
+    return TRUE;
+}
+
+Bool
+glamor_set_texture(PixmapPtr    pixmap,
+                   PixmapPtr    texture,
+                   int          off_x,
+                   int          off_y,
+                   GLint        offset_uniform,
+                   GLint        size_uniform)
+{
+    glamor_pixmap_private *texture_priv;
+
+    texture_priv = glamor_get_pixmap_private(texture);
+
+    if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(texture_priv))
+        return FALSE;
+
+    if (texture_priv->type == GLAMOR_TEXTURE_LARGE)
+        return FALSE;
+
+    glActiveTexture(GL_TEXTURE0);
+    glBindTexture(GL_TEXTURE_2D, texture_priv->base.fbo->tex);
+
+    glUniform2f(offset_uniform, off_x, off_y);
+    glUniform2f(size_uniform, texture->drawable.width, texture->drawable.height);
+    return TRUE;
+}
+
+Bool
+glamor_set_tiled(PixmapPtr      pixmap,
+                 GCPtr          gc,
+                 GLint          offset_uniform,
+                 GLint          size_uniform)
+{
+    if (!glamor_set_alu(pixmap->drawable.pScreen, gc->alu))
+        return FALSE;
+
+    if (!glamor_set_planemask(pixmap, gc->planemask))
+        return FALSE;
+
+    return glamor_set_texture(pixmap,
+                              gc->tile.pixmap,
+                              -gc->patOrg.x,
+                              -gc->patOrg.y,
+                              offset_uniform,
+                              size_uniform);
+}
+
+Bool
+glamor_set_stippled(PixmapPtr      pixmap,
+                    GCPtr          gc,
+                    GLint          fg_uniform,
+                    GLint          offset_uniform,
+                    GLint          size_uniform)
+{
+    if (!glamor_set_solid(pixmap, gc, TRUE, fg_uniform))
+        return FALSE;
+
+    if (!glamor_set_texture(pixmap, gc->stipple, gc->patOrg.x, gc->patOrg.y, offset_uniform, size_uniform))
+        return FALSE;
+
+    return TRUE;
+}
diff --git a/glamor/glamor_transform.h b/glamor/glamor_transform.h
new file mode 100644
index 0000000..36b789a
--- /dev/null
+++ b/glamor/glamor_transform.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright © 2014 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#ifndef _GLAMOR_TRANSFORM_H_
+#define _GLAMOR_TRANSFORM_H_
+
+void
+glamor_set_destination_drawable(DrawablePtr     drawable,
+                                int             box_x,
+                                int             box_y,
+                                Bool            do_drawable_translate,
+                                Bool            center_offset,
+                                GLint           matrix_uniform_location,
+                                int             *p_off_x,
+                                int             *p_off_y);
+
+void
+glamor_set_color(PixmapPtr      pixmap,
+                 CARD32         pixel,
+                 GLint          uniform);
+
+Bool
+glamor_set_texture(PixmapPtr    pixmap,
+                   PixmapPtr    texture,
+                   int          off_x,
+                   int          off_y,
+                   GLint        offset_uniform,
+                   GLint        size_uniform);
+
+Bool
+glamor_set_solid(PixmapPtr      pixmap,
+                 GCPtr          gc,
+                 Bool           use_alu,
+                 GLint          uniform);
+
+Bool
+glamor_set_tiled(PixmapPtr      pixmap,
+                 GCPtr          gc,
+                 GLint          offset_uniform,
+                 GLint          size_uniform);
+
+Bool
+glamor_set_stippled(PixmapPtr      pixmap,
+                    GCPtr          gc,
+                    GLint          fg_uniform,
+                    GLint          offset_uniform,
+                    GLint          size_uniform);
+
+/*
+ * Vertex shader bits that transform X coordinates to pixmap
+ * coordinates using the matrix computed above
+ */
+
+#define GLAMOR_DECLARE_MATRIX   "uniform vec4 v_matrix;\n"
+#define GLAMOR_X_POS(x) #x " *v_matrix.x + v_matrix.y"
+#define GLAMOR_Y_POS(y) #y " *v_matrix.z + v_matrix.w"
+#if 0
+#define GLAMOR_POS(dst,src) \
+    "       " #dst ".x = " #src ".x * v_matrix.x + v_matrix.y;\n" \
+    "       " #dst ".y = " #src ".y * v_matrix.z + v_matrix.w;\n" \
+    "       " #dst ".z = 0.0;\n" \
+    "       " #dst ".w = 1.0;\n"
+#endif
+#define GLAMOR_POS(dst,src) \
+    "       " #dst ".xy = " #src ".xy * v_matrix.xz + v_matrix.yw;\n" \
+    "       " #dst ".zw = vec2(0.0,1.0);\n"
+
+#endif /* _GLAMOR_TRANSFORM_H_ */
commit 0ca7223742e9ec0594203b3a99b11441730cca1a
Author: Keith Packard <keithp at keithp.com>
Date:   Thu Mar 13 23:12:27 2014 -0700

    glamor: Add helper functions to walk pixmap tiling
    
    This adds a few helper functions to make pixmap fbo access symmetrical
    between the single fbo and tiled cases.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Signed-off-by: Eric Anholt <eric at anholt.net>

diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 22b561d..ed2c767 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -471,6 +471,52 @@ typedef struct glamor_pixmap_private {
     };
 } glamor_pixmap_private;
 
+static inline glamor_pixmap_fbo *
+glamor_pixmap_fbo_at(glamor_pixmap_private *priv, int x, int y)
+{
+    if (priv->type == GLAMOR_TEXTURE_LARGE) {
+        assert(x < priv->large.block_wcnt);
+        assert(y < priv->large.block_hcnt);
+        return priv->large.fbo_array[y * priv->large.block_wcnt + x];
+    }
+    assert (x == 0);
+    assert (y == 0);
+    return priv->base.fbo;
+}
+
+static inline BoxPtr
+glamor_pixmap_box_at(glamor_pixmap_private *priv, int x, int y)
+{
+    if (priv->type == GLAMOR_TEXTURE_LARGE) {
+        assert(x < priv->large.block_wcnt);
+        assert(y < priv->large.block_hcnt);
+        return &priv->large.box_array[y * priv->large.block_wcnt + x];
+    }
+    assert (x == 0);
+    assert (y == 0);
+    return &priv->base.box;
+}
+
+static inline int
+glamor_pixmap_wcnt(glamor_pixmap_private *priv)
+{
+    if (priv->type == GLAMOR_TEXTURE_LARGE)
+        return priv->large.block_wcnt;
+    return 1;
+}
+
+static inline int
+glamor_pixmap_hcnt(glamor_pixmap_private *priv)
+{
+    if (priv->type == GLAMOR_TEXTURE_LARGE)
+        return priv->large.block_hcnt;
+    return 1;
+}
+
+#define glamor_pixmap_loop(priv, x, y)                  \
+    for (y = 0; y < glamor_pixmap_hcnt(priv); y++)      \
+        for (x = 0; x < glamor_pixmap_wcnt(priv); x++)
+
 /* 
  * Pixmap dynamic status, used by dynamic upload feature.
  *
commit 209d004469391420130262059af43a813b2c07d7
Author: Keith Packard <keithp at keithp.com>
Date:   Thu Mar 13 23:11:40 2014 -0700

    glamor: Add bounding box to one-fbo pixmaps
    
    This lets code treat the one-fbo pixmaps more symmetrically with the
    tiled pixmaps.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Signed-off-by: Eric Anholt <eric at anholt.net>

diff --git a/glamor/glamor.c b/glamor/glamor.c
index 22a79e8..3094432 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -76,6 +76,10 @@ glamor_set_pixmap_type(PixmapPtr pixmap, glamor_pixmap_type_t type)
         pixmap_priv->base.glamor_priv = glamor_priv;
     }
     pixmap_priv->type = type;
+    pixmap_priv->base.box.x1 = 0;
+    pixmap_priv->base.box.x2 = pixmap->drawable.width;
+    pixmap_priv->base.box.y1 = 0;
+    pixmap_priv->base.box.y2 = pixmap->drawable.height;
 }
 
 _X_EXPORT void
@@ -182,6 +186,10 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
         glamor_check_fbo_size(glamor_priv, w, h))
     {
         pixmap_priv->type = type;
+        pixmap_priv->base.box.x1 = 0;
+        pixmap_priv->base.box.y1 = 0;
+        pixmap_priv->base.box.x2 = w;
+        pixmap_priv->base.box.y2 = h;
         fbo = glamor_create_fbo(glamor_priv, w, h, format, usage);
     }
     else {
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 833450e..22b561d 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -415,6 +415,7 @@ typedef struct glamor_pixmap_private_base {
     unsigned char gl_tex:1;
     glamor_pixmap_fbo *fbo;
     PixmapPtr pixmap;
+    BoxRec box;
     int drm_stride;
     glamor_screen_private *glamor_priv;
     PicturePtr picture;
commit 82f91433e277e3711678c1b16be85e89b6c7d530
Author: Keith Packard <keithp at keithp.com>
Date:   Tue Mar 18 21:23:24 2014 -0700

    glamor: Get testing code using small FBOs working again
    
    Glamor has a mode where pixmaps will be constructed from numerous
    small FBOs. This allows testing of the tiled pixmap code without
    needing to create huge pixmaps.
    
    However, the render glyph code assumed that it could create a pixmap
    large enough for the glyph atlas. Instead of attempting to fix that
    (which would be disruptive and not helpful), I've added a new pixmap
    creation usage, GLAMOR_CREATE_NO_LARGE which forces allocation of a
    single large FBO.
    
    Now that we have pixmaps with varying FBO sizes, I then went around
    and fixed the few places using the global FBO max size and replaced
    that with the per-pixmap FBO tiling sizes, which were already present
    in each large pixmap.
    
    Xephyr has been changed to pass GLAMOR_CREATE_NO_LARGE when it creates
    the screen pixmap as it doesn't want to deal with tiling either.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Eric Anholt <eric at anholt.net>

diff --git a/glamor/glamor.c b/glamor/glamor.c
index 0d0f52c..22a79e8 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -178,7 +178,9 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
     pitch = (((w * pixmap->drawable.bitsPerPixel + 7) / 8) + 3) & ~3;
     screen->ModifyPixmapHeader(pixmap, w, h, 0, 0, pitch, NULL);
 
-    if (type == GLAMOR_MEMORY_MAP || glamor_check_fbo_size(glamor_priv, w, h)) {
+    if (type == GLAMOR_MEMORY_MAP || usage == GLAMOR_CREATE_NO_LARGE ||
+        glamor_check_fbo_size(glamor_priv, w, h))
+    {
         pixmap_priv->type = type;
         fbo = glamor_create_fbo(glamor_priv, w, h, format, usage);
     }
diff --git a/glamor/glamor.h b/glamor/glamor.h
index d05d2f4..11ec493 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -140,9 +140,16 @@ extern _X_EXPORT void glamor_set_pixmap_type(PixmapPtr pixmap,
                                              glamor_pixmap_type_t type);
 extern _X_EXPORT void glamor_destroy_textured_pixmap(PixmapPtr pixmap);
 extern _X_EXPORT void glamor_block_handler(ScreenPtr screen);
+
 extern _X_EXPORT PixmapPtr glamor_create_pixmap(ScreenPtr screen, int w, int h,
                                                 int depth, unsigned int usage);
 
+#define GLAMOR_CREATE_PIXMAP_CPU        0x100
+#define GLAMOR_CREATE_PIXMAP_FIXUP      0x101
+#define GLAMOR_CREATE_FBO_NO_FBO        0x103
+#define GLAMOR_CREATE_PIXMAP_MAP        0x104
+#define GLAMOR_CREATE_NO_LARGE          0x105
+
 /* @glamor_egl_exchange_buffers: Exchange the underlying buffers(KHR image,fbo).
  *
  * @front: front pixmap.
diff --git a/glamor/glamor_fbo.c b/glamor/glamor_fbo.c
index 640b6fd..4f6da67 100644
--- a/glamor/glamor_fbo.c
+++ b/glamor/glamor_fbo.c
@@ -361,9 +361,6 @@ glamor_create_fbo(glamor_screen_private *glamor_priv,
     GLint tex = 0;
     int cache_flag;
 
-    if (!glamor_check_fbo_size(glamor_priv, w, h))
-        return NULL;
-
     if (flag == GLAMOR_CREATE_FBO_NO_FBO)
         goto new_fbo;
 
diff --git a/glamor/glamor_glyphs.c b/glamor/glamor_glyphs.c
index 2b2c735..a04ae82 100644
--- a/glamor/glamor_glyphs.c
+++ b/glamor/glamor_glyphs.c
@@ -332,7 +332,7 @@ glamor_realize_glyph_caches(ScreenPtr pScreen)
         pixmap = pScreen->CreatePixmap(pScreen,
                                        CACHE_PICTURE_SIZE,
                                        CACHE_PICTURE_SIZE + MASK_CACHE_MAX_SIZE,
-                                       depth, 0);
+                                       depth, GLAMOR_CREATE_NO_LARGE);
         if (!pixmap)
             goto bail;
 
diff --git a/glamor/glamor_largepixmap.c b/glamor/glamor_largepixmap.c
index b8c0640..b3a8d5d 100644
--- a/glamor/glamor_largepixmap.c
+++ b/glamor/glamor_largepixmap.c
@@ -1015,7 +1015,6 @@ glamor_composite_largepixmap_region(CARD8 op,
                                     INT16 x_dest, INT16 y_dest,
                                     CARD16 width, CARD16 height)
 {
-    glamor_screen_private *glamor_priv;
     glamor_pixmap_clipped_regions *clipped_dest_regions;
     glamor_pixmap_clipped_regions *clipped_source_regions;
     glamor_pixmap_clipped_regions *clipped_mask_regions;
@@ -1044,9 +1043,8 @@ glamor_composite_largepixmap_region(CARD8 op,
     else
         mask_repeat_type = RepeatNone;
 
-    glamor_priv = dest_pixmap_priv->base.glamor_priv;
-    fixed_block_width = glamor_priv->max_fbo_size;
-    fixed_block_height = glamor_priv->max_fbo_size;
+    fixed_block_width = dest_pixmap_priv->large.block_w;
+    fixed_block_height = dest_pixmap_priv->large.block_h;
     /* If we got an totally out-of-box region for a source or mask
      * region without repeat, we need to set it as null_source and
      * give it a solid color (0,0,0,0). */
@@ -1112,8 +1110,8 @@ glamor_composite_largepixmap_region(CARD8 op,
 
     /*compute the correct block width and height whose transformed source/mask
      *region can fit into one texture.*/
-    if (force_clip || fixed_block_width < glamor_priv->max_fbo_size
-        || fixed_block_height < glamor_priv->max_fbo_size)
+    if (force_clip || fixed_block_width < dest_pixmap_priv->large.block_w
+        || fixed_block_height < dest_pixmap_priv->large.block_h)
         clipped_dest_regions =
             glamor_compute_clipped_regions_ext(dest_pixmap_priv, region,
                                                &n_dest_regions,
diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c
index 615faad..891ecdd 100644
--- a/glamor/glamor_pixmap.c
+++ b/glamor/glamor_pixmap.c
@@ -1013,10 +1013,9 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w,
             clipped_regions =
                 glamor_compute_clipped_regions_ext(pixmap_priv, &region,
                                                    &n_region,
-                                                   pixmap_priv->base.
-                                                   glamor_priv->max_fbo_size,
-                                                   pixmap_priv->base.
-                                                   glamor_priv->max_fbo_size, 0,
+                                                   pixmap_priv->large.block_w,
+                                                   pixmap_priv->large.block_h,
+                                                   0,
                                                    0);
         DEBUGF("prepare upload %dx%d to a large pixmap %p\n", w, h, pixmap);
         for (i = 0; i < n_region; i++) {
@@ -1374,10 +1373,9 @@ glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, int x, int y, int w, int h,
             clipped_regions =
                 glamor_compute_clipped_regions_ext(pixmap_priv, &region,
                                                    &n_region,
-                                                   pixmap_priv->base.
-                                                   glamor_priv->max_fbo_size,
-                                                   pixmap_priv->base.
-                                                   glamor_priv->max_fbo_size, 0,
+                                                   pixmap_priv->large.block_w,
+                                                   pixmap_priv->large.block_h,
+                                                   0,
                                                    0);
 
         DEBUGF("start download large pixmap %p %dx%d \n", pixmap, w, h);
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index d4d2e75..833450e 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -153,13 +153,6 @@ enum glamor_gl_flavor {
     GLAMOR_GL_ES2               // OPENGL ES2.0 API
 };
 
-#define GLAMOR_CREATE_PIXMAP_CPU  0x100
-#define GLAMOR_CREATE_PIXMAP_FIXUP 0x101
-#define GLAMOR_CREATE_FBO_NO_FBO   0x103
-#define GLAMOR_CREATE_PIXMAP_MAP 0x104
-
-#define GLAMOR_CREATE_TEXTURE_EXACT_SIZE 0x104
-
 #define GLAMOR_NUM_GLYPH_CACHE_FORMATS 2
 
 #define GLAMOR_COMPOSITE_VBO_VERT_CNT (64*1024)
diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 3260d95..3054f5f 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -1260,7 +1260,9 @@ ephyr_glamor_create_screen_resources(ScreenPtr pScreen)
     screen_pixmap = pScreen->CreatePixmap(pScreen,
                                           pScreen->width,
                                           pScreen->height,
-                                          pScreen->rootDepth, 0);
+                                          pScreen->rootDepth,
+                                          GLAMOR_CREATE_NO_LARGE);
+
     pScreen->SetScreenPixmap(screen_pixmap);
 
     /* Tell the GLX code what to GL texture to read from. */
commit 11e2f0de71fa341f8b0b1da0a1b9ccbfa6550a50
Author: Keith Packard <keithp at keithp.com>
Date:   Tue Mar 18 21:35:41 2014 -0700

    mi: miPutImage with XYPixmap failed at depth 32 on 64-bit machines
    
    The X server still has 'unsigned long' in a few places to hold 32 bit
    values. One of those is in miPutImage where it's holding the temporary
    planemask for XYPixmap format images.
    
    It computed the highest plane in the source image with 1 << (depth -
    1). On 64-bit machines, taking that value and storing it in an
    unsigned long promotes it to a signed 64-bit value
    (0xffffffff80000000).
    
    Then, it loops over that value, shifting one bit right each time,
    waiting for it to go to zero.. That takes 64 iterations, and ends up
    with some mystic planemask values *and* walking off the end of the
    source image data and out into space.
    
    A simple cast is all that is required to compute the correct initial
    plane mask (0x0000000080000000), at which point the loop operates
    correctly once again.
    
    Checking the fbPutImage code, I note that this same bug was fixed
    in 2006 by Aaron Plattner in commit
    f39fd4242902eaa862321d39337f429dd14ebacf
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Aaron Plattner <aplattner at nvidia.com>

diff --git a/mi/mibitblt.c b/mi/mibitblt.c
index b0d14ae..3ed4ed1 100644
--- a/mi/mibitblt.c
+++ b/mi/mibitblt.c
@@ -730,7 +730,7 @@ miPutImage(DrawablePtr pDraw, GCPtr pGC, int depth,
         ChangeGC(NullClient, pGC, GCForeground | GCBackground, gcv);
         bytesPer = (long) h *BitmapBytePad(w + leftPad);
 
-        for (i = 1 << (depth - 1); i != 0; i >>= 1, pImage += bytesPer) {
+        for (i = (unsigned long) 1 << (depth - 1); i != 0; i >>= 1, pImage += bytesPer) {
             if (i & oldPlanemask) {
                 gcv[0].val = (XID) i;
                 ChangeGC(NullClient, pGC, GCPlaneMask, gcv);
commit ae87b536155207e6e28b68963593a7ab09792e08
Author: Keith Packard <keithp at keithp.com>
Date:   Sat Mar 15 23:53:53 2014 -0700

    dix: Allow NULL stipple in ChangeGC
    
    miOpqStipDrawable resets the stipple after painting. When that stipple
    was NULL, ChangeGC needs to handle that and not crash.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-off-by: Eric Anholt <eric at anholt.net>

diff --git a/dix/gc.c b/dix/gc.c
index efe6d60..88d6501 100644
--- a/dix/gc.c
+++ b/dix/gc.c
@@ -261,12 +261,14 @@ ChangeGC(ClientPtr client, GC * pGC, BITS32 mask, ChangeGCValPtr pUnion)
         case GCStipple:
             NEXT_PTR(PixmapPtr, pPixmap);
 
-            if ((pPixmap->drawable.depth != 1) ||
-                (pPixmap->drawable.pScreen != pGC->pScreen)) {
+            if (pPixmap && ((pPixmap->drawable.depth != 1) ||
+                            (pPixmap->drawable.pScreen != pGC->pScreen)))
+            {
                 error = BadMatch;
             }
             else {
-                pPixmap->refcnt++;
+                if (pPixmap)
+                    pPixmap->refcnt++;
                 if (pGC->stipple)
                     (*pGC->pScreen->DestroyPixmap) (pGC->stipple);
                 pGC->stipple = pPixmap;
commit 2e040f41de18f4d46e649561b6efb043195fdfbe
Author: Markus Wick <markus at selfnet.de>
Date:   Tue Mar 18 09:42:55 2014 +0100

    glamor: Drop feature dependent optimization on startup.
    
    We don't care that much about startup time to write different code paths...
    
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Eric Anholt <eric at anholt.net>

diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index 62236b9..cdf8eff 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -412,27 +412,10 @@ glamor_init_composite_shaders(ScreenPtr screen)
 
     eb_size = GLAMOR_COMPOSITE_VBO_VERT_CNT * sizeof(short) * 2;
 
-    if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
-        glBufferData(GL_ELEMENT_ARRAY_BUFFER, eb_size, NULL, GL_STATIC_DRAW);
-        eb = glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY);
-    }
-    else {
-        eb = malloc(eb_size);
-    }
-
-    if (eb == NULL)
-        FatalError
-            ("fatal error, fail to get element buffer. GL context may be not created correctly.\n");
+    eb = XNFalloc(eb_size);
     glamor_init_eb(eb, GLAMOR_COMPOSITE_VBO_VERT_CNT);
-
-    if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
-        glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER);
-    }
-    else {
-        glBufferData(GL_ELEMENT_ARRAY_BUFFER, eb_size, eb, GL_STATIC_DRAW);
-
-        free(eb);
-    }
+    glBufferData(GL_ELEMENT_ARRAY_BUFFER, eb_size, eb, GL_STATIC_DRAW);
+    free(eb);
 
     glamor_put_context(glamor_priv);
 }
commit 2e75d974bcfdd879d7417cc02892b78eaea5e888
Author: Markus Wick <markus at selfnet.de>
Date:   Tue Mar 18 09:42:54 2014 +0100

    glamor: Remove unneeded unbindings.
    
    They are already cleared in glamor_put_vbo_space.
    
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Eric Anholt <eric at anholt.net>

diff --git a/glamor/glamor_gradient.c b/glamor/glamor_gradient.c
index ce24d73..c24f342 100644
--- a/glamor/glamor_gradient.c
+++ b/glamor/glamor_gradient.c
@@ -1120,8 +1120,6 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
         free(stop_colors);
     }
 
-    glBindBuffer(GL_ARRAY_BUFFER, 0);
-
     glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
     glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
 
@@ -1140,8 +1138,6 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
             free(stop_colors);
     }
 
-    glBindBuffer(GL_ARRAY_BUFFER, 0);
-
     glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
     glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
     glamor_put_context(glamor_priv);
@@ -1469,8 +1465,6 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
         free(stop_colors);
     }
 
-    glBindBuffer(GL_ARRAY_BUFFER, 0);
-
     glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
     glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
 
@@ -1489,8 +1483,6 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
             free(stop_colors);
     }
 
-    glBindBuffer(GL_ARRAY_BUFFER, 0);
-
     glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
     glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
     glamor_put_context(glamor_priv);
commit 7c4e1472966d9d3d6432621c3114f491a5378604
Author: Markus Wick <markus at selfnet.de>
Date:   Tue Mar 18 09:42:53 2014 +0100

    glamor: Always keep GL_ELEMENT_ARRAY_BUFFER bound to the same IB.
    
    We never used glDrawElements() with a different index buffer.
    
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Eric Anholt <eric at anholt.net>

diff --git a/glamor/glamor_fill.c b/glamor/glamor_fill.c
index 7461b62..2fa726e 100644
--- a/glamor/glamor_fill.c
+++ b/glamor/glamor_fill.c
@@ -218,9 +218,6 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
         }
     }
 
-    if (_X_UNLIKELY(nbox > 1))
-        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glamor_priv->ebo);
-
     glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
                           GL_FALSE, 2 * sizeof(float), vertices);
     glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
diff --git a/glamor/glamor_gradient.c b/glamor/glamor_gradient.c
index 38dac68..ce24d73 100644
--- a/glamor/glamor_gradient.c
+++ b/glamor/glamor_gradient.c
@@ -1121,7 +1121,6 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
     }
 
     glBindBuffer(GL_ARRAY_BUFFER, 0);
-    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
 
     glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
     glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
@@ -1142,7 +1141,6 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
     }
 
     glBindBuffer(GL_ARRAY_BUFFER, 0);
-    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
 
     glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
     glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
@@ -1472,7 +1470,6 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
     }
 
     glBindBuffer(GL_ARRAY_BUFFER, 0);
-    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
 
     glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
     glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
@@ -1493,7 +1490,6 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
     }
 
     glBindBuffer(GL_ARRAY_BUFFER, 0);
-    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
 
     glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
     glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index c0ee22c..62236b9 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -427,11 +427,9 @@ glamor_init_composite_shaders(ScreenPtr screen)
 
     if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
         glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER);
-        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
     }
     else {
         glBufferData(GL_ELEMENT_ARRAY_BUFFER, eb_size, eb, GL_STATIC_DRAW);
-        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
 
         free(eb);
     }
@@ -448,6 +446,7 @@ glamor_fini_composite_shaders(ScreenPtr screen)
 
     glamor_priv = glamor_get_screen_private(screen);
     glamor_get_context(glamor_priv);
+    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
     glDeleteBuffers(1, &glamor_priv->ebo);
 
     for (i = 0; i < SHADER_SOURCE_COUNT; i++)
@@ -706,8 +705,6 @@ glamor_setup_composite_vbo(ScreenPtr screen, int n_verts)
     glamor_get_context(glamor_priv);
     vb = glamor_get_vbo_space(screen, vert_size, &vbo_offset);
 
-    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glamor_priv->ebo);
-
     glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT, GL_FALSE,
                           glamor_priv->vb_stride, vbo_offset);
     glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
@@ -1329,7 +1326,6 @@ glamor_composite_with_shader(CARD8 op,
         }
     }
 
-    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
     glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
     glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
     glDisableVertexAttribArray(GLAMOR_VERTEX_MASK);
diff --git a/glamor/glamor_trapezoid.c b/glamor/glamor_trapezoid.c
index 969ab68..c76b8bb 100644
--- a/glamor/glamor_trapezoid.c
+++ b/glamor/glamor_trapezoid.c
@@ -637,8 +637,6 @@ glamor_setup_composite_vbo_for_trapezoid(ScreenPtr screen, int n_verts)
 
     vb = glamor_get_vbo_space(screen, vert_size, &vbo_offset);
 
-    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glamor_priv->ebo);
-
     /* Set the vertex pointer. */
     glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
                           GL_FALSE, glamor_priv->vb_stride,
@@ -977,7 +975,6 @@ _glamor_trapezoids_with_shader(CARD8 op,
     ret = TRUE;
 
  TRAPEZOID_RESET_GL:
-    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
     glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
     glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
     glDisableVertexAttribArray(GLAMOR_VERTEX_MASK);
@@ -1415,8 +1412,6 @@ _glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture,
 
     pixmap_priv_get_dest_scale(pixmap_priv, (&xscale), (&yscale));
 
-    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
-
     /* Now draw the Trapezoid mask. */
     glUseProgram(trapezoid_prog);
 
@@ -1562,7 +1557,6 @@ _glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture,
         }
     }
 
-    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
     glBlendFunc(GL_ONE, GL_ZERO);
     glDisable(GL_BLEND);
     glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
commit 82168b1e6ede48898be8a64b1c93b7d82ef65702
Author: Markus Wick <markus at selfnet.de>
Date:   Tue Mar 18 09:42:52 2014 +0100

    glamor: Select VBO path by ARB_mbr extension.
    
    The mbr path was hard coded enabled for desktop gl and disabled for
    gles.  But there are both desktop without mbr and GLES with mbr.
    
    v2: Don't forget to update the fini path, too (change by anholt)
    
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Eric Anholt <eric at anholt.net>

diff --git a/glamor/glamor.c b/glamor/glamor.c
index eb13430..0d0f52c 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -378,6 +378,8 @@ glamor_init(ScreenPtr screen, unsigned int flags)
         epoxy_has_gl_extension("GL_MESA_pack_invert");
     glamor_priv->has_fbo_blit =
         epoxy_has_gl_extension("GL_EXT_framebuffer_blit");
+    glamor_priv->has_map_buffer_range =
+        epoxy_has_gl_extension("GL_ARB_map_buffer_range");
     glamor_priv->has_buffer_storage =
         epoxy_has_gl_extension("GL_ARB_buffer_storage");
     glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &glamor_priv->max_fbo_size);
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 0f0b0f3..d4d2e75 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -213,6 +213,7 @@ typedef struct glamor_screen_private {
     enum glamor_gl_flavor gl_flavor;
     int has_pack_invert;
     int has_fbo_blit;
+    int has_map_buffer_range;
     int has_buffer_storage;
     int has_khr_debug;
     int max_fbo_size;
diff --git a/glamor/glamor_vbo.c b/glamor/glamor_vbo.c
index 5e98bfe..2731692 100644
--- a/glamor/glamor_vbo.c
+++ b/glamor/glamor_vbo.c
@@ -96,7 +96,7 @@ glamor_get_vbo_space(ScreenPtr screen, unsigned size, char **vbo_offset)
         *vbo_offset = (void *)(uintptr_t)glamor_priv->vbo_offset;
         data = glamor_priv->vb + glamor_priv->vbo_offset;
         glamor_priv->vbo_offset += size;
-    } else if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
+    } else if (glamor_priv->has_map_buffer_range) {
         if (glamor_priv->vbo_size < glamor_priv->vbo_offset + size) {
             glamor_priv->vbo_size = MAX(GLAMOR_VBO_SIZE, size);
             glamor_priv->vbo_offset = 0;
@@ -147,7 +147,7 @@ glamor_put_vbo_space(ScreenPtr screen)
          * persistent mapping, so we can leave it around until we
          * reach the end of the buffer.
          */
-    } else if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
+    } else if (glamor_priv->has_map_buffer_range) {
         glUnmapBuffer(GL_ARRAY_BUFFER);
     } else {
         glBufferData(GL_ARRAY_BUFFER, glamor_priv->vbo_offset,
@@ -179,7 +179,7 @@ glamor_fini_vbo(ScreenPtr screen)
     glamor_get_context(glamor_priv);
 
     glDeleteBuffers(1, &glamor_priv->vbo);
-    if (glamor_priv->gl_flavor != GLAMOR_GL_DESKTOP)
+    if (!glamor_priv->has_map_buffer_range)
         free(glamor_priv->vb);
 
     glamor_put_context(glamor_priv);
commit 53df6e8c3bd7025883b9614a549fbf268c110b74
Author: Markus Wick <markus at selfnet.de>
Date:   Tue Mar 18 09:42:51 2014 +0100

    glamor: Update GL requirements to 2.1.
    
    We will never ever run on OpenGL 1.2 as we use shaders everywhere.
    2.0 may be enough, but we also often use PBOs and our big shaders
    won't fit into the first GLSL limits.
    
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Eric Anholt <eric at anholt.net>

diff --git a/glamor/glamor.c b/glamor/glamor.c
index ef969e2..eb13430 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -357,8 +357,8 @@ glamor_init(ScreenPtr screen, unsigned int flags)
      * Windows with Intel 4-series (G45) graphics or older.
      */
     if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
-        if (gl_version < 13) {
-            ErrorF("Require OpenGL version 1.3 or later.\n");
+        if (gl_version < 21) {
+            ErrorF("Require OpenGL version 2.1 or later.\n");
             goto fail;
         }
     } else {
commit 15d36444acc7a2890ade8e320dc16d627a9d2035
Author: Markus Wick <markus at selfnet.de>
Date:   Tue Mar 18 09:42:50 2014 +0100

    glamor: Use epoxy_gl_version() instead of rolling our own.
    
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Eric Anholt <eric at anholt.net>

diff --git a/glamor/glamor.c b/glamor/glamor.c
index 9d171b7..ef969e2 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -341,7 +341,7 @@ glamor_init(ScreenPtr screen, unsigned int flags)
     else
         glamor_priv->gl_flavor = GLAMOR_GL_ES2;
 
-    gl_version = glamor_gl_get_version();
+    gl_version = epoxy_gl_version();
 
     /* We'd like to require GL_ARB_map_buffer_range or
      * GL_OES_map_buffer_range, since it offers more information to
@@ -357,12 +357,12 @@ glamor_init(ScreenPtr screen, unsigned int flags)
      * Windows with Intel 4-series (G45) graphics or older.
      */
     if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
-        if (gl_version < GLAMOR_GL_VERSION_ENCODE(1, 3)) {
+        if (gl_version < 13) {
             ErrorF("Require OpenGL version 1.3 or later.\n");
             goto fail;
         }
     } else {
-        if (gl_version < GLAMOR_GL_VERSION_ENCODE(2, 0)) {
+        if (gl_version < 20) {
             ErrorF("Require Open GLES2.0 or later.\n");
             goto fail;
         }
diff --git a/glamor/glamor_core.c b/glamor/glamor_core.c
index eeaa595..5711be7 100644
--- a/glamor/glamor_core.c
+++ b/glamor/glamor_core.c
@@ -559,26 +559,3 @@ glamor_bitmap_to_region(PixmapPtr pixmap)
     return ret;
 }
 
-int
-glamor_gl_get_version(void)
-{
-    int major, minor;
-    const char *version = (const char *) glGetString(GL_VERSION);
-    const char *dot = version == NULL ? NULL : strchr(version, '.');
-    const char *major_start = dot;
-
-    /* Sanity check */
-    if (dot == NULL || dot == version || *(dot + 1) == '\0') {
-        major = 0;
-        minor = 0;
-    }
-    else {
-        /* Find the start of the major version in the string */
-        while (major_start > version && *major_start != ' ')
-            --major_start;
-        major = strtol(major_start, NULL, 10);
-        minor = strtol(dot + 1, NULL, 10);
-    }
-
-    return GLAMOR_GL_VERSION_ENCODE(major, minor);
-}
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index f278bef..0f0b0f3 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -619,11 +619,6 @@ Bool glamor_set_alu(ScreenPtr screen, unsigned char alu);
 Bool glamor_set_planemask(PixmapPtr pixmap, unsigned long planemask);
 Bool glamor_change_window_attributes(WindowPtr pWin, unsigned long mask);
 RegionPtr glamor_bitmap_to_region(PixmapPtr pixmap);
-int glamor_gl_get_version(void);
-
-#define GLAMOR_GL_VERSION_ENCODE(major, minor) ( \
-          ((major) * 256)                       \
-        + ((minor) *   1))
 
 /* glamor_fill.c */
 Bool glamor_fill(DrawablePtr drawable,
commit 9d87f66e862a521553d48aa73e5ee97431d36ad3
Author: Markus Wick <markus at selfnet.de>
Date:   Tue Mar 18 09:42:49 2014 +0100

    glamor: Use epoxy_has_gl_extension() instead of rolling our own.
    
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Eric Anholt <eric at anholt.net>

diff --git a/glamor/glamor.c b/glamor/glamor.c
index 0f7d68b..9d171b7 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -367,19 +367,19 @@ glamor_init(ScreenPtr screen, unsigned int flags)
             goto fail;
         }
 
-        if (!glamor_gl_has_extension("GL_EXT_texture_format_BGRA8888")) {
+        if (!epoxy_has_gl_extension("GL_EXT_texture_format_BGRA8888")) {
             ErrorF("GL_EXT_texture_format_BGRA8888 required\n");
             goto fail;
         }
     }
 
-    glamor_priv->has_khr_debug = glamor_gl_has_extension("GL_KHR_debug");
+    glamor_priv->has_khr_debug = epoxy_has_gl_extension("GL_KHR_debug");
     glamor_priv->has_pack_invert =
-        glamor_gl_has_extension("GL_MESA_pack_invert");
+        epoxy_has_gl_extension("GL_MESA_pack_invert");
     glamor_priv->has_fbo_blit =
-        glamor_gl_has_extension("GL_EXT_framebuffer_blit");
+        epoxy_has_gl_extension("GL_EXT_framebuffer_blit");
     glamor_priv->has_buffer_storage =
-        glamor_gl_has_extension("GL_ARB_buffer_storage");
+        epoxy_has_gl_extension("GL_ARB_buffer_storage");
     glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &glamor_priv->max_fbo_size);
 #ifdef MAX_FBO_SIZE
     glamor_priv->max_fbo_size = MAX_FBO_SIZE;
diff --git a/glamor/glamor_core.c b/glamor/glamor_core.c
index 6c0b3c8..eeaa595 100644
--- a/glamor/glamor_core.c
+++ b/glamor/glamor_core.c
@@ -559,28 +559,6 @@ glamor_bitmap_to_region(PixmapPtr pixmap)
     return ret;
 }
 
-/* Borrow from cairo. */
-Bool
-glamor_gl_has_extension(const char *extension)
-{
-    const char *pext;
-    int ext_len;
-
-    ext_len = strlen(extension);
-
-    pext = (const char *) glGetString(GL_EXTENSIONS);
-
-    if (pext == NULL || extension == NULL)
-        return FALSE;
-
-    while ((pext = strstr(pext, extension)) != NULL) {
-        if (pext[ext_len] == ' ' || pext[ext_len] == '\0')
-            return TRUE;
-        pext += ext_len;
-    }
-    return FALSE;
-}
-
 int
 glamor_gl_get_version(void)
 {
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index bc7d3f8..f278bef 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -619,7 +619,6 @@ Bool glamor_set_alu(ScreenPtr screen, unsigned char alu);
 Bool glamor_set_planemask(PixmapPtr pixmap, unsigned long planemask);
 Bool glamor_change_window_attributes(WindowPtr pWin, unsigned long mask);
 RegionPtr glamor_bitmap_to_region(PixmapPtr pixmap);
-Bool glamor_gl_has_extension(const char *extension);
 int glamor_gl_get_version(void);
 
 #define GLAMOR_GL_VERSION_ENCODE(major, minor) ( \
commit 708fe0625f31ad39ba54f27f04d17ed2aa621cad
Author: Markus Wick <markus at selfnet.de>
Date:   Tue Mar 18 09:42:48 2014 +0100

    glamor: Use glsl "fract/mod" instead of "while" in gradient shaders.
    
    This fixes gtkperf. It seemed to hang forever.
    
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Eric Anholt <eric at anholt.net>

diff --git a/glamor/glamor_gradient.c b/glamor/glamor_gradient.c
index f77d6a8..38dac68 100644
--- a/glamor/glamor_gradient.c
+++ b/glamor/glamor_gradient.c
@@ -247,7 +247,6 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, int stops_count,
 	    "{\n"\
 	    "    float t = 0.0;\n"\
 	    "    float sqrt_value;\n"\
-	    "    int revserse = 0;\n"\
 	    "    t_invalid = 0;\n"\
 	    "    \n"\
 	    "    vec3 tmp = vec3(source_texture.x, source_texture.y, 1.0);\n"\
@@ -295,30 +294,11 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, int stops_count,
 	    "    }\n"\
 	    "    \n"\
 	    "    if(repeat_type == %d){\n" /* repeat normal*/\
-	    "        while(t > 1.0) \n"\
-	    "            t = t - 1.0; \n"\
-	    "        while(t < 0.0) \n"\
-	    "            t = t + 1.0; \n"\
+	    "        t = fract(t);\n"\
 	    "    }\n"\
 	    "    \n"\
 	    "    if(repeat_type == %d) {\n" /* repeat reflect*/\
-	    "        while(t > 1.0) {\n"\
-	    "            t = t - 1.0; \n"\
-	    "            if(revserse == 0)\n"\
-	    "                revserse = 1;\n"\
-	    "            else\n"\
-	    "                revserse = 0;\n"\
-	    "        }\n"\
-	    "        while(t < 0.0) {\n"\
-	    "            t = t + 1.0; \n"\
-	    "            if(revserse == 0)\n"\
-	    "                revserse = 1;\n"\
-	    "            else\n"\
-	    "                revserse = 0;\n"\
-	    "        }\n"\
-	    "        if(revserse == 1) {\n"\
-	    "            t = 1.0 - t; \n"\
-	    "        }\n"\
+	    "        t = abs(fract(t * 0.5 + 0.5) * 2.0 - 1.0);\n"\
 	    "    }\n"\
 	    "    \n"\
 	    "    return t;\n"\
@@ -492,7 +472,6 @@ _glamor_create_linear_gradient_program(ScreenPtr screen, int stops_count,
 	    "    vec4 stop_color_before;\n"\
 	    "    vec4 stop_color_after;\n"\
 	    "    float new_alpha; \n"\
-	    "    int revserse = 0;\n"\
 	    "    vec4 gradient_color;\n"\
 	    "    float percentage; \n"\
 	    "    vec3 source_texture_trans = transform_mat * tmp;\n"\
@@ -512,30 +491,11 @@ _glamor_create_linear_gradient_program(ScreenPtr screen, int stops_count,
 	    "    distance = distance - _p1_distance; \n"\
 	    "    \n"\
 	    "    if(repeat_type == %d){\n" /* repeat normal*/\
-	    "        while(distance > _pt_distance) \n"\
-	    "            distance = distance - (_pt_distance); \n"\
-	    "        while(distance < 0.0) \n"\
-	    "            distance = distance + (_pt_distance); \n"\
+	    "        distance = mod(distance, _pt_distance);\n"\
 	    "    }\n"\
 	    "    \n"\
 	    "    if(repeat_type == %d) {\n" /* repeat reflect*/\
-	    "        while(distance > _pt_distance) {\n"\
-	    "            distance = distance - (_pt_distance); \n"\
-	    "            if(revserse == 0)\n"\
-	    "                revserse = 1;\n"\
-	    "            else\n"\
-	    "                revserse = 0;\n"\
-	    "        }\n"\
-	    "        while(distance < 0.0) {\n"\
-	    "            distance = distance + (_pt_distance); \n"\
-	    "            if(revserse == 0)\n"\
-	    "                revserse = 1;\n"\
-	    "            else\n"\
-	    "                revserse = 0;\n"\
-	    "        }\n"\
-	    "        if(revserse == 1) {\n"\
-	    "            distance = (_pt_distance) - distance; \n"\
-	    "        }\n"\
+	    "        distance = abs(mod(distance + _pt_distance, 2.0 * _pt_distance) - _pt_distance);\n"\
 	    "    }\n"\
 	    "    \n"\
 	    "    len_percentage = distance/(_pt_distance);\n"\
commit 84ff8960722fa9baf6ad70756b9c335bf2a5e515
Author: Eric Anholt <eric at anholt.net>
Date:   Tue Mar 18 09:42:47 2014 +0100

    kdrive: Remove duplicated definitions of some XV-related structs.
    
    v2: Fix crash because of removed strdup. (by Markus Wick)
    
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Eric Anholt <eric at anholt.net> (v2)

diff --git a/hw/kdrive/src/kxv.c b/hw/kdrive/src/kxv.c
index 445eb60..9cc0edd 100644
--- a/hw/kdrive/src/kxv.c
+++ b/hw/kdrive/src/kxv.c
@@ -385,28 +385,7 @@ KdXVInitAdaptors(ScreenPtr pScreen, KdVideoAdaptorPtr * infoPtr, int number)
 
             for (i = 0, pi = pImage, imagePtr = adaptorPtr->pImages;
                  i < adaptorPtr->nImages; i++, pi++, imagePtr++) {
-                pi->id = imagePtr->id;
-                pi->type = imagePtr->type;
-                pi->byte_order = imagePtr->byte_order;
-                memcpy(pi->guid, imagePtr->guid, 16);
-                pi->bits_per_pixel = imagePtr->bits_per_pixel;
-                pi->format = imagePtr->format;
-                pi->num_planes = imagePtr->num_planes;
-                pi->depth = imagePtr->depth;
-                pi->red_mask = imagePtr->red_mask;
-                pi->green_mask = imagePtr->green_mask;
-                pi->blue_mask = imagePtr->blue_mask;
-                pi->y_sample_bits = imagePtr->y_sample_bits;
-                pi->u_sample_bits = imagePtr->u_sample_bits;
-                pi->v_sample_bits = imagePtr->v_sample_bits;
-                pi->horz_y_period = imagePtr->horz_y_period;
-                pi->horz_u_period = imagePtr->horz_u_period;
-                pi->horz_v_period = imagePtr->horz_v_period;
-                pi->vert_y_period = imagePtr->vert_y_period;
-                pi->vert_u_period = imagePtr->vert_u_period;
-                pi->vert_v_period = imagePtr->vert_v_period;
-                memcpy(pi->component_order, imagePtr->component_order, 32);
-                pi->scanline_order = imagePtr->scanline_order;
+                memcpy(pi, imagePtr, sizeof(*pi));
             }
             pa->nImages = adaptorPtr->nImages;
             pa->pImages = pImage;
@@ -417,9 +396,7 @@ KdXVInitAdaptors(ScreenPtr pScreen, KdVideoAdaptorPtr * infoPtr, int number)
              calloc(adaptorPtr->nAttributes, sizeof(XvAttributeRec)))) {
             for (pat = pAttribute, attributePtr = adaptorPtr->pAttributes, i =
                  0; i < adaptorPtr->nAttributes; pat++, i++, attributePtr++) {
-                pat->flags = attributePtr->flags;
-                pat->min_value = attributePtr->min_value;
-                pat->max_value = attributePtr->max_value;
+                memcpy(pat, attributePtr, sizeof(*pat));
                 pat->name = strdup(attributePtr->name);
             }
             pa->nAttributes = adaptorPtr->nAttributes;
diff --git a/hw/kdrive/src/kxv.h b/hw/kdrive/src/kxv.h
index 4f644c2..85a030e 100644
--- a/hw/kdrive/src/kxv.h
+++ b/hw/kdrive/src/kxv.h
@@ -56,34 +56,7 @@ of the copyright holder.
 #define VIDEO_OVERLAID_STILLS			0x00000008
 #define VIDEO_CLIP_TO_VIEWPORT			0x00000010
 
-typedef struct {
-    int id;
-    int type;
-    int byte_order;
-    unsigned char guid[16];
-    int bits_per_pixel;
-    int format;
-    int num_planes;
-
-    /* for RGB formats only */
-    int depth;
-    unsigned int red_mask;
-    unsigned int green_mask;
-    unsigned int blue_mask;
-
-    /* for YUV formats only */
-    unsigned int y_sample_bits;
-    unsigned int u_sample_bits;
-    unsigned int v_sample_bits;
-    unsigned int horz_y_period;
-    unsigned int horz_u_period;
-    unsigned int horz_v_period;
-    unsigned int vert_y_period;
-    unsigned int vert_u_period;
-    unsigned int vert_v_period;
-    char component_order[32];
-    int scanline_order;
-} KdImageRec, *KdImagePtr;
+typedef XvImageRec KdImageRec, *KdImagePtr;
 
 typedef struct {
     KdScreenInfo *screen;
@@ -158,12 +131,7 @@ typedef struct {
     short class;
 } KdVideoFormatRec, *KdVideoFormatPtr;
 
-typedef struct {
-    int flags;
-    int min_value;
-    int max_value;
-    char *name;
-} KdAttributeRec, *KdAttributePtr;
+typedef XvAttributeRec KdAttributeRec, *KdAttributePtr;
 
 typedef struct {
     unsigned int type;
commit 370c8c75ca6aebb5d93d2ab87c9c8ffac21fc57d
Author: Gaetan Nadon <memsize at videotron.ca>
Date:   Wed Mar 19 11:28:57 2014 -0400

    xfree86: glamor_egl subdir must be distributed - breaks distcheck
    
    Signed-off-by: Gaetan Nadon <memsize at videotron.ca>
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Eric Anholt <eric at anholt.net>

diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am
index a315bbc..18fa99b 100644
--- a/hw/xfree86/Makefile.am
+++ b/hw/xfree86/Makefile.am
@@ -43,7 +43,7 @@ SUBDIRS = common ddc x86emu $(INT10_SUBDIR) os-support parser \
 DIST_SUBDIRS = common ddc i2c x86emu int10 fbdevhw os-support \
                parser ramdac shadowfb vbe vgahw \
                loader dixmods dri dri2 exa modes \
-	       utils doc man
+	       utils doc man glamor_egl
 
 bin_PROGRAMS = Xorg
 nodist_Xorg_SOURCES = sdksyms.c
commit 870bbf85e63a59f252f3ea9d63e28f083359d990
Author: Gaetan Nadon <memsize at videotron.ca>
Date:   Wed Mar 19 14:17:15 2014 -0400

    ephyr: typo where "()" should be "$()" in the Makefile - breaks make dist
    
    make[3]: Entering directory `/home/nadon/xorg/src/xserver/hw/kdrive/ephyr'
    make[3]: *** No rule to make target `()', needed by `distdir'.  Stop.
    make[3]: Leaving directory `/home/nadon/xorg/src/xserver/hw/kdrive/ephyr'
    make[2]: *** [distdir] Error 1
    
    Signed-off-by: Gaetan Nadon <memsize at videotron.ca>
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Eric Anholt <eric at anholt.net>

diff --git a/hw/kdrive/ephyr/Makefile.am b/hw/kdrive/ephyr/Makefile.am
index 040993c..00a53d0 100644
--- a/hw/kdrive/ephyr/Makefile.am
+++ b/hw/kdrive/ephyr/Makefile.am
@@ -38,7 +38,7 @@ if GLAMOR
 GLAMOR_SRCS = \
 	ephyr_glamor_glx.c \
 	ephyr_glamor_glx.h \
-	()
+	$()
 endif
 
 if DRI


More information about the xorg-commit mailing list