[PATCH 1/8] glamor: Convert to using libepoxy.

Eric Anholt eric at anholt.net
Mon Feb 3 10:36:42 PST 2014


Libepoxy hides all the GL versus GLES2 dispatch handling for us, with
higher performance.

Signed-off-by: Eric Anholt <eric at anholt.net>
---

Sadly, while this diff is big, it was written by hand.

 configure.ac                |   2 +-
 glamor/Makefile.am          |   3 -
 glamor/glamor.c             |  14 +-
 glamor/glamor_copyarea.c    | 114 ++++------
 glamor/glamor_core.c        | 124 +++++------
 glamor/glamor_egl.c         | 116 +++-------
 glamor/glamor_fbo.c         |  45 ++--
 glamor/glamor_fill.c        |  63 +++---
 glamor/glamor_gl_dispatch.c | 118 ----------
 glamor/glamor_gl_dispatch.h | 128 -----------
 glamor/glamor_glext.h       |  63 ------
 glamor/glamor_glyphs.c      |   6 +-
 glamor/glamor_gradient.c    | 515 +++++++++++++++++++++-----------------------
 glamor/glamor_pixmap.c      | 205 +++++++++---------
 glamor/glamor_priv.h        |  18 +-
 glamor/glamor_putimage.c    |  84 ++++----
 glamor/glamor_render.c      | 286 +++++++++++-------------
 glamor/glamor_tile.c        |  91 ++++----
 glamor/glamor_trapezoid.c   | 199 ++++++++---------
 glamor/glamor_utils.h       |   4 +-
 glamor/glamor_xv.c          | 140 ++++++------
 21 files changed, 898 insertions(+), 1440 deletions(-)
 delete mode 100644 glamor/glamor_gl_dispatch.c
 delete mode 100644 glamor/glamor_gl_dispatch.h
 delete mode 100644 glamor/glamor_glext.h

diff --git a/configure.ac b/configure.ac
index c6764f5..5946fe7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2069,7 +2069,7 @@ dnl glamor
 AM_CONDITIONAL([GLAMOR], [test "x$GLAMOR" = xyes])
 if test "x$GLAMOR" = xyes; then
 	AC_DEFINE(GLAMOR, 1, [Build glamor])
-	PKG_CHECK_MODULES([GLAMOR], [egl gl])
+	PKG_CHECK_MODULES([GLAMOR], [epoxy])
 fi
 
 dnl XWin DDX
diff --git a/glamor/Makefile.am b/glamor/Makefile.am
index 3fe2530..17cae97 100644
--- a/glamor/Makefile.am
+++ b/glamor/Makefile.am
@@ -10,11 +10,9 @@ libglamor_la_SOURCES = \
 	glamor_copywindow.c \
 	glamor_core.c \
 	glamor_debug.h \
-	glamor_gl_dispatch.h \
 	glamor_fill.c \
 	glamor_fillspans.c \
 	glamor_getspans.c \
-	glamor_glext.h \
 	glamor_glyphs.c \
 	glamor_polyfillrect.c \
 	glamor_polylines.c \
@@ -35,7 +33,6 @@ libglamor_la_SOURCES = \
 	glamor_largepixmap.c\
 	glamor_picture.c\
 	glamor_window.c\
-	glamor_gl_dispatch.c\
 	glamor_fbo.c\
 	glamor_compositerects.c\
 	glamor_xv.c\
diff --git a/glamor/glamor.c b/glamor/glamor.c
index feb110a..74ae150 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -218,11 +218,10 @@ void
 glamor_block_handler(ScreenPtr screen)
 {
     glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
-    glamor_gl_dispatch *dispatch;
 
-    dispatch = glamor_get_dispatch(glamor_priv);
+    glamor_get_dispatch(glamor_priv);
     glamor_priv->tick++;
-    dispatch->glFlush();
+    glFlush();
     glamor_fbo_expire(glamor_priv);
     glamor_put_dispatch(glamor_priv);
     if (glamor_priv->state == RENDER_STATE
@@ -236,9 +235,9 @@ static void
 _glamor_block_handler(void *data, OSTimePtr timeout, void *last_select_mask)
 {
     glamor_screen_private *glamor_priv = data;
-    glamor_gl_dispatch *dispatch = glamor_get_dispatch(glamor_priv);
 
-    dispatch->glFlush();
+    glamor_get_dispatch(glamor_priv);
+    glFlush();
     glamor_put_dispatch(glamor_priv);
 }
 
@@ -316,8 +315,6 @@ glamor_init(ScreenPtr screen, unsigned int flags)
     }
 #endif
 
-    glamor_gl_dispatch_init(screen, &glamor_priv->_dispatch, gl_version);
-
 #ifdef GLAMOR_GLES2
     if (!glamor_gl_has_extension("GL_EXT_texture_format_BGRA8888")) {
         ErrorF("GL_EXT_texture_format_BGRA8888 required\n");
@@ -329,8 +326,7 @@ glamor_init(ScreenPtr screen, unsigned int flags)
         glamor_gl_has_extension("GL_MESA_pack_invert");
     glamor_priv->has_fbo_blit =
         glamor_gl_has_extension("GL_EXT_framebuffer_blit");
-    glamor_priv->_dispatch.glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE,
-                                         &glamor_priv->max_fbo_size);
+    glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &glamor_priv->max_fbo_size);
 #ifdef MAX_FBO_SIZE
     glamor_priv->max_fbo_size = MAX_FBO_SIZE;
 #endif
diff --git a/glamor/glamor_copyarea.c b/glamor/glamor_copyarea.c
index 2735ba0..6eb0d98 100644
--- a/glamor/glamor_copyarea.c
+++ b/glamor/glamor_copyarea.c
@@ -42,7 +42,6 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
     PixmapPtr src_pixmap = glamor_get_drawable_pixmap(src);
     glamor_pixmap_private *src_pixmap_priv, *dst_pixmap_priv;
     glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
-    glamor_gl_dispatch *dispatch;
     int dst_x_off, dst_y_off, src_x_off, src_y_off, i;
     int fbo_x_off, fbo_y_off;
     int src_fbo_x_off, src_fbo_y_off;
@@ -72,9 +71,8 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
     pixmap_priv_get_fbo_off(dst_pixmap_priv, &fbo_x_off, &fbo_y_off);
     pixmap_priv_get_fbo_off(src_pixmap_priv, &src_fbo_x_off, &src_fbo_y_off);
 
-    dispatch = glamor_get_dispatch(glamor_priv);
-    dispatch->glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT,
-                                src_pixmap_priv->base.fbo->fb);
+    glamor_get_dispatch(glamor_priv);
+    glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, src_pixmap_priv->base.fbo->fb);
     glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off, &dst_y_off);
     glamor_get_drawable_deltas(src, src_pixmap, &src_x_off, &src_y_off);
     dst_x_off += fbo_x_off;
@@ -84,23 +82,15 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
 
     for (i = 0; i < nbox; i++) {
         if (glamor_priv->yInverted) {
-            dispatch->glBlitFramebuffer((box[i].x1 + dx +
-                                         src_x_off),
-                                        (box[i].y1 +
-                                         src_y_off),
-                                        (box[i].x2 + dx +
-                                         src_x_off),
-                                        (box[i].y2 +
-                                         src_y_off),
-                                        (box[i].x1 +
-                                         dst_x_off),
-                                        (box[i].y1 +
-                                         dst_y_off),
-                                        (box[i].x2 +
-                                         dst_x_off),
-                                        (box[i].y2 +
-                                         dst_y_off),
-                                        GL_COLOR_BUFFER_BIT, GL_NEAREST);
+            glBlitFramebuffer(box[i].x1 + dx + src_x_off,
+                              box[i].y1 + src_y_off,
+                              box[i].x2 + dx + src_x_off,
+                              box[i].y2 + src_y_off,
+                              box[i].x1 + dst_x_off,
+                              box[i].y1 + dst_y_off,
+                              box[i].x2 + dst_x_off,
+                              box[i].y2 + dst_y_off,
+                              GL_COLOR_BUFFER_BIT, GL_NEAREST);
         }
         else {
             int flip_dst_y1 =
@@ -112,19 +102,15 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
             int flip_src_y2 =
                 src_pixmap->drawable.height - (box[i].y1 + src_y_off);
 
-            dispatch->glBlitFramebuffer(box[i].x1 + dx +
-                                        src_x_off,
-                                        flip_src_y1,
-                                        box[i].x2 + dx +
-                                        src_x_off,
-                                        flip_src_y2,
-                                        box[i].x1 +
-                                        dst_x_off,
-                                        flip_dst_y1,
-                                        box[i].x2 +
-                                        dst_x_off,
-                                        flip_dst_y2,
-                                        GL_COLOR_BUFFER_BIT, GL_NEAREST);
+            glBlitFramebuffer(box[i].x1 + dx + src_x_off,
+                              flip_src_y1,
+                              box[i].x2 + dx + src_x_off,
+                              flip_src_y2,
+                              box[i].x1 + dst_x_off,
+                              flip_dst_y1,
+                              box[i].x2 + dst_x_off,
+                              flip_dst_y2,
+                              GL_COLOR_BUFFER_BIT, GL_NEAREST);
         }
     }
     glamor_put_dispatch(glamor_priv);
@@ -140,7 +126,6 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
 {
     glamor_screen_private *glamor_priv =
         glamor_get_screen_private(dst->pScreen);
-    glamor_gl_dispatch *dispatch;
     PixmapPtr src_pixmap = glamor_get_drawable_pixmap(src);
     PixmapPtr dst_pixmap = glamor_get_drawable_pixmap(dst);
     int i;
@@ -172,37 +157,33 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
 
     glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off, &dst_y_off);
 
-    dispatch = glamor_get_dispatch(glamor_priv);
+    glamor_get_dispatch(glamor_priv);
 
     glamor_set_destination_pixmap_priv_nc(dst_pixmap_priv);
-    dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
-                                    GL_FALSE, 2 * sizeof(float), vertices);
-    dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+    glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
+                          GL_FALSE, 2 * sizeof(float), vertices);
+    glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
 
     glamor_get_drawable_deltas(src, src_pixmap, &src_x_off, &src_y_off);
     dx += src_x_off;
     dy += src_y_off;
 
-    dispatch->glActiveTexture(GL_TEXTURE0);
-    dispatch->glBindTexture(GL_TEXTURE_2D, src_pixmap_priv->base.fbo->tex);
+    glActiveTexture(GL_TEXTURE0);
+    glBindTexture(GL_TEXTURE_2D, src_pixmap_priv->base.fbo->tex);
 #ifndef GLAMOR_GLES2
-    dispatch->glEnable(GL_TEXTURE_2D);
-    dispatch->glTexParameteri(GL_TEXTURE_2D,
-                              GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
-    dispatch->glTexParameteri(GL_TEXTURE_2D,
-                              GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
+    glEnable(GL_TEXTURE_2D);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
 #endif
-    dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-    dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-
-    dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
-                                    GL_FLOAT, GL_FALSE,
-                                    2 * sizeof(float), texcoords);
-    dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
-    dispatch->glUseProgram(glamor_priv->finish_access_prog[0]);
-    dispatch->glUniform1i(glamor_priv->finish_access_revert[0], REVERT_NONE);
-    dispatch->glUniform1i(glamor_priv->finish_access_swap_rb[0],
-                          SWAP_NONE_UPLOADING);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+
+    glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT, GL_FALSE,
+                          2 * sizeof(float), texcoords);
+    glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+    glUseProgram(glamor_priv->finish_access_prog[0]);
+    glUniform1i(glamor_priv->finish_access_revert[0], REVERT_NONE);
+    glUniform1i(glamor_priv->finish_access_swap_rb[0], SWAP_NONE_UPLOADING);
 
     for (i = 0; i < nbox; i++) {
 
@@ -222,15 +203,15 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
                                      box[i].x2 + dx,
                                      box[i].y2 + dy,
                                      glamor_priv->yInverted, texcoords);
-        dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+        glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
     }
 
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
 #ifndef GLAMOR_GLES2
-    dispatch->glDisable(GL_TEXTURE_2D);
+    glDisable(GL_TEXTURE_2D);
 #endif
-    dispatch->glUseProgram(0);
+    glUseProgram(0);
     /* The source texture is bound to a fbo, we have to flush it here. */
     glamor_put_dispatch(glamor_priv);
     glamor_priv->state = RENDER_STATE;
@@ -367,7 +348,6 @@ _glamor_copy_n_to_n(DrawablePtr src,
     PixmapPtr dst_pixmap, src_pixmap;
     glamor_pixmap_private *dst_pixmap_priv, *src_pixmap_priv;
     glamor_screen_private *glamor_priv;
-    glamor_gl_dispatch *dispatch;
     BoxPtr extent;
     RegionRec region;
     int src_x_off, src_y_off, dst_x_off, dst_y_off;
@@ -394,8 +374,8 @@ _glamor_copy_n_to_n(DrawablePtr src,
     if (gc) {
         if (!glamor_set_planemask(dst_pixmap, gc->planemask))
             goto fall_back;
-        dispatch = glamor_get_dispatch(glamor_priv);
-        if (!glamor_set_alu(dispatch, gc->alu)) {
+        glamor_get_dispatch(glamor_priv);
+        if (!glamor_set_alu(gc->alu)) {
             glamor_put_dispatch(glamor_priv);
             goto fail;
         }
@@ -572,8 +552,8 @@ _glamor_copy_n_to_n(DrawablePtr src,
     }
 
  fail:
-    dispatch = glamor_get_dispatch(glamor_priv);
-    glamor_set_alu(dispatch, GXcopy);
+    glamor_get_dispatch(glamor_priv);
+    glamor_set_alu(GXcopy);
     glamor_put_dispatch(glamor_priv);
 
     if (ok)
diff --git a/glamor/glamor_core.c b/glamor/glamor_core.c
index 4eac856..b69d092 100644
--- a/glamor/glamor_core.c
+++ b/glamor/glamor_core.c
@@ -51,24 +51,23 @@ glamor_get_drawable_location(const DrawablePtr drawable)
 }
 
 GLint
-glamor_compile_glsl_prog(glamor_gl_dispatch * dispatch, GLenum type,
-                         const char *source)
+glamor_compile_glsl_prog(GLenum type, const char *source)
 {
     GLint ok;
     GLint prog;
 
-    prog = dispatch->glCreateShader(type);
-    dispatch->glShaderSource(prog, 1, (const GLchar **) &source, NULL);
-    dispatch->glCompileShader(prog);
-    dispatch->glGetShaderiv(prog, GL_COMPILE_STATUS, &ok);
+    prog = glCreateShader(type);
+    glShaderSource(prog, 1, (const GLchar **) &source, NULL);
+    glCompileShader(prog);
+    glGetShaderiv(prog, GL_COMPILE_STATUS, &ok);
     if (!ok) {
         GLchar *info;
         GLint size;
 
-        dispatch->glGetShaderiv(prog, GL_INFO_LOG_LENGTH, &size);
+        glGetShaderiv(prog, GL_INFO_LOG_LENGTH, &size);
         info = malloc(size);
         if (info) {
-            dispatch->glGetShaderInfoLog(prog, size, NULL, info);
+            glGetShaderInfoLog(prog, size, NULL, info);
             ErrorF("Failed to compile %s: %s\n",
                    type == GL_FRAGMENT_SHADER ? "FS" : "VS", info);
             ErrorF("Program source:\n%s", source);
@@ -83,20 +82,20 @@ glamor_compile_glsl_prog(glamor_gl_dispatch * dispatch, GLenum type,
 }
 
 void
-glamor_link_glsl_prog(glamor_gl_dispatch * dispatch, GLint prog)
+glamor_link_glsl_prog(GLint prog)
 {
     GLint ok;
 
-    dispatch->glLinkProgram(prog);
-    dispatch->glGetProgramiv(prog, GL_LINK_STATUS, &ok);
+    glLinkProgram(prog);
+    glGetProgramiv(prog, GL_LINK_STATUS, &ok);
     if (!ok) {
         GLchar *info;
         GLint size;
 
-        dispatch->glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &size);
+        glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &size);
         info = malloc(size);
 
-        dispatch->glGetProgramInfoLog(prog, size, NULL, info);
+        glGetProgramInfoLog(prog, size, NULL, info);
         ErrorF("Failed to link: %s\n", info);
         FatalError("GLSL link failure\n");
     }
@@ -143,7 +142,6 @@ void
 glamor_init_finish_access_shaders(ScreenPtr screen)
 {
     glamor_screen_private *glamor_priv;
-    glamor_gl_dispatch *dispatch;
     const char *vs_source =
         "attribute vec4 v_position;\n"
         "attribute vec4 v_texcoord0;\n"
@@ -217,72 +215,65 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
     char *source;
 
     glamor_priv = glamor_get_screen_private(screen);
-    dispatch = glamor_get_dispatch(glamor_priv);
-    glamor_priv->finish_access_prog[0] = dispatch->glCreateProgram();
-    glamor_priv->finish_access_prog[1] = dispatch->glCreateProgram();
+    glamor_priv->finish_access_prog[0] = glCreateProgram();
+    glamor_priv->finish_access_prog[1] = glCreateProgram();
 
-    vs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, vs_source);
+    vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, vs_source);
 
     XNFasprintf(&source, "%s%s", common_source, fs_source);
-    fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER, source);
+    fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, source);
     free(source);
 
-    dispatch->glAttachShader(glamor_priv->finish_access_prog[0], vs_prog);
-    dispatch->glAttachShader(glamor_priv->finish_access_prog[0], fs_prog);
+    glAttachShader(glamor_priv->finish_access_prog[0], vs_prog);
+    glAttachShader(glamor_priv->finish_access_prog[0], fs_prog);
 
-    avs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, vs_source);
+    avs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, vs_source);
 
     XNFasprintf(&source, "%s%s", common_source, set_alpha_source);
-    set_alpha_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
+    set_alpha_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER,
                                               source);
     free(source);
 
-    dispatch->glAttachShader(glamor_priv->finish_access_prog[1], avs_prog);
-    dispatch->glAttachShader(glamor_priv->finish_access_prog[1],
-                             set_alpha_prog);
+    glamor_get_dispatch(glamor_priv);
+    glAttachShader(glamor_priv->finish_access_prog[1], avs_prog);
+    glAttachShader(glamor_priv->finish_access_prog[1], set_alpha_prog);
 
-    dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[0],
-                                   GLAMOR_VERTEX_POS, "v_position");
-    dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[0],
-                                   GLAMOR_VERTEX_SOURCE, "v_texcoord0");
-    glamor_link_glsl_prog(dispatch, glamor_priv->finish_access_prog[0]);
+    glBindAttribLocation(glamor_priv->finish_access_prog[0],
+                         GLAMOR_VERTEX_POS, "v_position");
+    glBindAttribLocation(glamor_priv->finish_access_prog[0],
+                         GLAMOR_VERTEX_SOURCE, "v_texcoord0");
+    glamor_link_glsl_prog(glamor_priv->finish_access_prog[0]);
 
-    dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[1],
-                                   GLAMOR_VERTEX_POS, "v_position");
-    dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[1],
-                                   GLAMOR_VERTEX_SOURCE, "v_texcoord0");
-    glamor_link_glsl_prog(dispatch, glamor_priv->finish_access_prog[1]);
+    glBindAttribLocation(glamor_priv->finish_access_prog[1],
+                         GLAMOR_VERTEX_POS, "v_position");
+    glBindAttribLocation(glamor_priv->finish_access_prog[1],
+                         GLAMOR_VERTEX_SOURCE, "v_texcoord0");
+    glamor_link_glsl_prog(glamor_priv->finish_access_prog[1]);
 
     glamor_priv->finish_access_revert[0] =
-        dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[0],
-                                       "revert");
+        glGetUniformLocation(glamor_priv->finish_access_prog[0], "revert");
 
     glamor_priv->finish_access_swap_rb[0] =
-        dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[0],
-                                       "swap_rb");
+        glGetUniformLocation(glamor_priv->finish_access_prog[0], "swap_rb");
     sampler_uniform_location =
-        dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[0],
-                                       "sampler");
-    dispatch->glUseProgram(glamor_priv->finish_access_prog[0]);
-    dispatch->glUniform1i(sampler_uniform_location, 0);
-    dispatch->glUniform1i(glamor_priv->finish_access_revert[0], 0);
-    dispatch->glUniform1i(glamor_priv->finish_access_swap_rb[0], 0);
-    dispatch->glUseProgram(0);
+        glGetUniformLocation(glamor_priv->finish_access_prog[0], "sampler");
+    glUseProgram(glamor_priv->finish_access_prog[0]);
+    glUniform1i(sampler_uniform_location, 0);
+    glUniform1i(glamor_priv->finish_access_revert[0], 0);
+    glUniform1i(glamor_priv->finish_access_swap_rb[0], 0);
+    glUseProgram(0);
 
     glamor_priv->finish_access_revert[1] =
-        dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[1],
-                                       "revert");
+        glGetUniformLocation(glamor_priv->finish_access_prog[1], "revert");
     glamor_priv->finish_access_swap_rb[1] =
-        dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[1],
-                                       "swap_rb");
+        glGetUniformLocation(glamor_priv->finish_access_prog[1], "swap_rb");
     sampler_uniform_location =
-        dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[1],
-                                       "sampler");
-    dispatch->glUseProgram(glamor_priv->finish_access_prog[1]);
-    dispatch->glUniform1i(glamor_priv->finish_access_revert[1], 0);
-    dispatch->glUniform1i(sampler_uniform_location, 0);
-    dispatch->glUniform1i(glamor_priv->finish_access_swap_rb[1], 0);
-    dispatch->glUseProgram(0);
+        glGetUniformLocation(glamor_priv->finish_access_prog[1], "sampler");
+    glUseProgram(glamor_priv->finish_access_prog[1]);
+    glUniform1i(glamor_priv->finish_access_revert[1], 0);
+    glUniform1i(sampler_uniform_location, 0);
+    glUniform1i(glamor_priv->finish_access_swap_rb[1], 0);
+    glUseProgram(0);
     glamor_put_dispatch(glamor_priv);
 }
 
@@ -290,12 +281,11 @@ void
 glamor_fini_finish_access_shaders(ScreenPtr screen)
 {
     glamor_screen_private *glamor_priv;
-    glamor_gl_dispatch *dispatch;
 
     glamor_priv = glamor_get_screen_private(screen);
-    dispatch = glamor_get_dispatch(glamor_priv);
-    dispatch->glDeleteProgram(glamor_priv->finish_access_prog[0]);
-    dispatch->glDeleteProgram(glamor_priv->finish_access_prog[1]);
+    glamor_get_dispatch(glamor_priv);
+    glDeleteProgram(glamor_priv->finish_access_prog[0]);
+    glDeleteProgram(glamor_priv->finish_access_prog[1]);
     glamor_put_dispatch(glamor_priv);
 }
 
@@ -315,14 +305,12 @@ glamor_finish_access(DrawablePtr drawable, glamor_access_t access_mode)
     }
 
     if (pixmap_priv->base.fbo->pbo != 0 && pixmap_priv->base.fbo->pbo_valid) {
-        glamor_gl_dispatch *dispatch;
-
         assert(glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP);
 
-        dispatch = glamor_get_dispatch(glamor_priv);
-        dispatch->glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
-        dispatch->glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
-        dispatch->glDeleteBuffers(1, &pixmap_priv->base.fbo->pbo);
+        glamor_get_dispatch(glamor_priv);
+        glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
+        glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
+        glDeleteBuffers(1, &pixmap_priv->base.fbo->pbo);
         glamor_put_dispatch(glamor_priv);
 
         pixmap_priv->base.fbo->pbo_valid = FALSE;
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 2f97a83..906598a 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -37,8 +37,6 @@
 #include <errno.h>
 #include <xf86.h>
 #include <xf86drm.h>
-#define GL_GLEXT_PROTOTYPES
-#define EGL_EGLEXT_PROTOTYPES
 #define EGL_DISPLAY_NO_X_MESA
 
 #ifdef GLAMOR_HAS_GBM
@@ -46,19 +44,11 @@
 #include <drm_fourcc.h>
 #endif
 
-#if GLAMOR_GLES2
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-#else
-#include <GL/gl.h>
-#endif
-
 #define MESA_EGL_NO_X11_HEADERS
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
+#include <epoxy/gl.h>
+#include <epoxy/egl.h>
 
 #include "glamor.h"
-#include "glamor_gl_dispatch.h"
 
 static const char glamor_name[] = "glamor";
 
@@ -91,10 +81,6 @@ struct glamor_egl_screen_private {
     int gl_context_depth;
     int dri3_capable;
 
-    PFNEGLCREATEIMAGEKHRPROC egl_create_image_khr;
-    PFNEGLDESTROYIMAGEKHRPROC egl_destroy_image_khr;
-    PFNGLEGLIMAGETARGETTEXTURE2DOESPROC egl_image_target_texture2d_oes;
-    struct glamor_gl_dispatch *dispatch;
     CloseScreenProcPtr saved_close_screen;
     xf86FreeScreenProc *saved_free_screen;
 };
@@ -164,11 +150,11 @@ _glamor_egl_create_image(struct glamor_egl_screen_private *glamor_egl,
     attribs[5] = stride;
     if (depth != 32 && depth != 24)
         return EGL_NO_IMAGE_KHR;
-    image = glamor_egl->egl_create_image_khr(glamor_egl->display,
-                                             glamor_egl->context,
-                                             EGL_DRM_BUFFER_MESA,
-                                             (void *) (uintptr_t) name,
-                                             attribs);
+    image = eglCreateImageKHR(glamor_egl->display,
+                              glamor_egl->context,
+                              EGL_DRM_BUFFER_MESA,
+                              (void *) (uintptr_t) name,
+                              attribs);
     if (image == EGL_NO_IMAGE_KHR)
         return EGL_NO_IMAGE_KHR;
 
@@ -192,15 +178,13 @@ glamor_create_texture_from_image(struct glamor_egl_screen_private
                                  *glamor_egl,
                                  EGLImageKHR image, GLuint * texture)
 {
-    glamor_egl->dispatch->glGenTextures(1, texture);
-    glamor_egl->dispatch->glBindTexture(GL_TEXTURE_2D, *texture);
-    glamor_egl->dispatch->glTexParameteri(GL_TEXTURE_2D,
-                                          GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-    glamor_egl->dispatch->glTexParameteri(GL_TEXTURE_2D,
-                                          GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-
-    (glamor_egl->egl_image_target_texture2d_oes) (GL_TEXTURE_2D, image);
-    glamor_egl->dispatch->glBindTexture(GL_TEXTURE_2D, 0);
+    glGenTextures(1, texture);
+    glBindTexture(GL_TEXTURE_2D, *texture);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+
+    glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
+    glBindTexture(GL_TEXTURE_2D, 0);
     return TRUE;
 }
 
@@ -228,15 +212,15 @@ glamor_egl_create_argb8888_based_texture(ScreenPtr screen, int w, int h)
      * compile with dri3 support enabled */
     native_pixmap = bo;
 
-    image = glamor_egl->egl_create_image_khr(glamor_egl->display,
-                                             EGL_NO_CONTEXT,
-                                             EGL_NATIVE_PIXMAP_KHR,
-                                             native_pixmap, NULL);
+    image = eglCreateImageKHR(glamor_egl->display,
+                              EGL_NO_CONTEXT,
+                              EGL_NATIVE_PIXMAP_KHR,
+                              native_pixmap, NULL);
     gbm_bo_destroy(bo);
     if (image == EGL_NO_IMAGE_KHR)
         return 0;
     glamor_create_texture_from_image(glamor_egl, image, &texture);
-    glamor_egl->egl_destroy_image_khr(glamor_egl->display, image);
+    eglDestroyImageKHR(glamor_egl->display, image);
 
     return texture;
 #else
@@ -356,9 +340,9 @@ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, void *bo)
 
     glamor_egl_make_current(screen);
 
-    image = glamor_egl->egl_create_image_khr(glamor_egl->display,
-                                             glamor_egl->context,
-                                             EGL_NATIVE_PIXMAP_KHR, bo, NULL);
+    image = eglCreateImageKHR(glamor_egl->display,
+                              glamor_egl->context,
+                              EGL_NATIVE_PIXMAP_KHR, bo, NULL);
     if (image == EGL_NO_IMAGE_KHR) {
         glamor_set_pixmap_type(pixmap, GLAMOR_DRM_ONLY);
         goto done;
@@ -430,11 +414,11 @@ glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen,
                              glamor_egl_pixmap_private_key);
 
     if (image == EGL_NO_IMAGE_KHR || image == NULL) {
-        image = glamor_egl->egl_create_image_khr(glamor_egl->display,
-                                                 glamor_egl->context,
-                                                 EGL_GL_TEXTURE_2D_KHR,
-                                                 (EGLClientBuffer) (uintptr_t)
-                                                 tex, attribs);
+        image = eglCreateImageKHR(glamor_egl->display,
+                                  glamor_egl->context,
+                                  EGL_GL_TEXTURE_2D_KHR,
+                                  (EGLClientBuffer) (uintptr_t)
+                                  tex, attribs);
         if (image == EGL_NO_IMAGE_KHR)
             goto failure;
 
@@ -506,10 +490,10 @@ glamor_egl_dri3_pixmap_from_fd(ScreenPtr screen,
     attribs[3] = height;
     attribs[7] = fd;
     attribs[11] = stride;
-    image = glamor_egl->egl_create_image_khr(glamor_egl->display,
-                                             EGL_NO_CONTEXT,
-                                             EGL_LINUX_DMA_BUF_EXT,
-                                             NULL, attribs);
+    image = eglCreateImageKHR(glamor_egl->display,
+                              EGL_NO_CONTEXT,
+                              EGL_LINUX_DMA_BUF_EXT,
+                              NULL, attribs);
 
     if (image == EGL_NO_IMAGE_KHR)
         return NULL;
@@ -518,7 +502,7 @@ glamor_egl_dri3_pixmap_from_fd(ScreenPtr screen,
      * usage of the image. Use gbm_bo to bypass the limitations. */
 
     bo = gbm_bo_import(glamor_egl->gbm, GBM_BO_IMPORT_EGL_IMAGE, image, 0);
-    glamor_egl->egl_destroy_image_khr(glamor_egl->display, image);
+    eglDestroyImageKHR(glamor_egl->display, image);
 
     if (!bo)
         return NULL;
@@ -555,7 +539,7 @@ _glamor_egl_destroy_pixmap_image(PixmapPtr pixmap)
          * a texture. we must call glFlush to make sure the
          * operation on that texture has been done.*/
         glamor_block_handler(pixmap->drawable.pScreen);
-        glamor_egl->egl_destroy_image_khr(glamor_egl->display, image);
+        eglDestroyImageKHR(glamor_egl->display, image);
         dixSetPrivate(&pixmap->devPrivates, glamor_egl_pixmap_private_key,
                       NULL);
     }
@@ -605,8 +589,7 @@ glamor_egl_close_screen(ScreenPtr screen)
     glamor_egl = glamor_egl_get_screen_private(scrn);
     screen_pixmap = screen->GetScreenPixmap(screen);
 
-    glamor_egl->egl_destroy_image_khr(glamor_egl->display,
-                                      glamor_egl->front_image);
+    eglDestroyImageKHR(glamor_egl->display,glamor_egl->front_image);
     dixSetPrivate(&screen_pixmap->devPrivates, glamor_egl_pixmap_private_key,
                   NULL);
     glamor_egl->front_image = NULL;
@@ -614,7 +597,7 @@ glamor_egl_close_screen(ScreenPtr screen)
         back_image = dixLookupPrivate(&(*glamor_egl->back_pixmap)->devPrivates,
                                       glamor_egl_pixmap_private_key);
         if (back_image != NULL && back_image != EGL_NO_IMAGE_KHR) {
-            glamor_egl->egl_destroy_image_khr(glamor_egl->display, back_image);
+            eglDestroyImageKHR(glamor_egl->display, back_image);
             dixSetPrivate(&(*glamor_egl->back_pixmap)->devPrivates,
                           glamor_egl_pixmap_private_key, NULL);
         }
@@ -751,21 +734,6 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
         glamor_egl_has_extension(glamor_egl, "EGL_EXT_image_dma_buf_import"))
         glamor_egl->dri3_capable = TRUE;
 #endif
-    glamor_egl->egl_create_image_khr = (PFNEGLCREATEIMAGEKHRPROC)
-        eglGetProcAddress("eglCreateImageKHR");
-
-    glamor_egl->egl_destroy_image_khr = (PFNEGLDESTROYIMAGEKHRPROC)
-        eglGetProcAddress("eglDestroyImageKHR");
-
-    glamor_egl->egl_image_target_texture2d_oes =
-        (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)
-        eglGetProcAddress("glEGLImageTargetTexture2DOES");
-
-    if (!glamor_egl->egl_create_image_khr
-        || !glamor_egl->egl_image_target_texture2d_oes) {
-        xf86DrvMsg(scrn->scrnIndex, X_ERROR, "eglGetProcAddress() failed\n");
-        return FALSE;
-    }
 
     glamor_egl->context = eglCreateContext(glamor_egl->display,
                                            NULL, EGL_NO_CONTEXT,
@@ -809,17 +777,3 @@ glamor_egl_init_textured_pixmap(ScreenPtr screen)
         glamor_enable_dri3(screen);
     return TRUE;
 }
-
-Bool
-glamor_gl_dispatch_init(ScreenPtr screen,
-                        struct glamor_gl_dispatch *dispatch, int gl_version)
-{
-    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
-    struct glamor_egl_screen_private *glamor_egl =
-        glamor_egl_get_screen_private(scrn);
-    if (!glamor_gl_dispatch_init_impl
-        (dispatch, gl_version, (get_proc_address_t) eglGetProcAddress))
-        return FALSE;
-    glamor_egl->dispatch = dispatch;
-    return TRUE;
-}
diff --git a/glamor/glamor_fbo.c b/glamor/glamor_fbo.c
index d94e530..bb7af2c 100644
--- a/glamor/glamor_fbo.c
+++ b/glamor/glamor_fbo.c
@@ -129,14 +129,14 @@ glamor_pixmap_fbo_cache_get(glamor_screen_private *glamor_priv,
 void
 glamor_purge_fbo(glamor_pixmap_fbo *fbo)
 {
-    glamor_gl_dispatch *dispatch = glamor_get_dispatch(fbo->glamor_priv);
+    glamor_get_dispatch(fbo->glamor_priv);
 
     if (fbo->fb)
-        dispatch->glDeleteFramebuffers(1, &fbo->fb);
+        glDeleteFramebuffers(1, &fbo->fb);
     if (fbo->tex)
-        dispatch->glDeleteTextures(1, &fbo->tex);
+        glDeleteTextures(1, &fbo->tex);
     if (fbo->pbo)
-        dispatch->glDeleteBuffers(1, &fbo->pbo);
+        glDeleteBuffers(1, &fbo->pbo);
     glamor_put_dispatch(fbo->glamor_priv);
 
     free(fbo);
@@ -178,19 +178,17 @@ glamor_pixmap_fbo_cache_put(glamor_pixmap_fbo *fbo)
 static void
 glamor_pixmap_ensure_fb(glamor_pixmap_fbo *fbo)
 {
-    glamor_gl_dispatch *dispatch;
     int status;
 
-    dispatch = glamor_get_dispatch(fbo->glamor_priv);
+    glamor_get_dispatch(fbo->glamor_priv);
 
     if (fbo->fb == 0)
-        dispatch->glGenFramebuffers(1, &fbo->fb);
+        glGenFramebuffers(1, &fbo->fb);
     assert(fbo->tex != 0);
-    dispatch->glBindFramebuffer(GL_FRAMEBUFFER, fbo->fb);
-    dispatch->glFramebufferTexture2D(GL_FRAMEBUFFER,
-                                     GL_COLOR_ATTACHMENT0,
-                                     GL_TEXTURE_2D, fbo->tex, 0);
-    status = dispatch->glCheckFramebufferStatus(GL_FRAMEBUFFER);
+    glBindFramebuffer(GL_FRAMEBUFFER, fbo->fb);
+    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+                           GL_TEXTURE_2D, fbo->tex, 0);
+    status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
     if (status != GL_FRAMEBUFFER_COMPLETE) {
         const char *str;
 
@@ -243,10 +241,8 @@ glamor_create_fbo_from_tex(glamor_screen_private *glamor_priv,
     fbo->glamor_priv = glamor_priv;
 
     if (flag == GLAMOR_CREATE_PIXMAP_MAP) {
-        glamor_gl_dispatch *dispatch;
-
-        dispatch = glamor_get_dispatch(glamor_priv);
-        dispatch->glGenBuffers(1, &fbo->pbo);
+        glamor_get_dispatch(glamor_priv);
+        glGenBuffers(1, &fbo->pbo);
         glamor_put_dispatch(glamor_priv);
         goto done;
     }
@@ -334,7 +330,6 @@ static int
 _glamor_create_tex(glamor_screen_private *glamor_priv,
                    int w, int h, GLenum format)
 {
-    glamor_gl_dispatch *dispatch;
     unsigned int tex = 0;
 
     /* With dri3, we want to allocate ARGB8888 pixmaps only.
@@ -346,15 +341,13 @@ _glamor_create_tex(glamor_screen_private *glamor_priv,
                                                        w, h);
     }
     if (!tex) {
-        dispatch = glamor_get_dispatch(glamor_priv);
-        dispatch->glGenTextures(1, &tex);
-        dispatch->glBindTexture(GL_TEXTURE_2D, tex);
-        dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
-                                  GL_NEAREST);
-        dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
-                                  GL_NEAREST);
-        dispatch->glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0,
-                               format, GL_UNSIGNED_BYTE, NULL);
+        glamor_get_dispatch(glamor_priv);
+        glGenTextures(1, &tex);
+        glBindTexture(GL_TEXTURE_2D, tex);
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+        glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0,
+                     format, GL_UNSIGNED_BYTE, NULL);
         glamor_put_dispatch(glamor_priv);
     }
     return tex;
diff --git a/glamor/glamor_fill.c b/glamor/glamor_fill.c
index d59e620..e98fc5b 100644
--- a/glamor/glamor_fill.c
+++ b/glamor/glamor_fill.c
@@ -137,7 +137,6 @@ void
 glamor_init_solid_shader(ScreenPtr screen)
 {
     glamor_screen_private *glamor_priv;
-    glamor_gl_dispatch *dispatch;
     const char *solid_vs =
         "attribute vec4 v_position;"
         "void main()\n"
@@ -154,19 +153,19 @@ glamor_init_solid_shader(ScreenPtr screen)
     GLint fs_prog, vs_prog;
 
     glamor_priv = glamor_get_screen_private(screen);
-    dispatch = glamor_get_dispatch(glamor_priv);
-    glamor_priv->solid_prog = dispatch->glCreateProgram();
-    vs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, solid_vs);
-    fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER, solid_fs);
-    dispatch->glAttachShader(glamor_priv->solid_prog, vs_prog);
-    dispatch->glAttachShader(glamor_priv->solid_prog, fs_prog);
+    glamor_get_dispatch(glamor_priv);
+    glamor_priv->solid_prog = glCreateProgram();
+    vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, solid_vs);
+    fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, solid_fs);
+    glAttachShader(glamor_priv->solid_prog, vs_prog);
+    glAttachShader(glamor_priv->solid_prog, fs_prog);
 
-    dispatch->glBindAttribLocation(glamor_priv->solid_prog,
-                                   GLAMOR_VERTEX_POS, "v_position");
-    glamor_link_glsl_prog(dispatch, glamor_priv->solid_prog);
+    glBindAttribLocation(glamor_priv->solid_prog,
+                         GLAMOR_VERTEX_POS, "v_position");
+    glamor_link_glsl_prog(glamor_priv->solid_prog);
 
     glamor_priv->solid_color_uniform_location =
-        dispatch->glGetUniformLocation(glamor_priv->solid_prog, "color");
+        glGetUniformLocation(glamor_priv->solid_prog, "color");
     glamor_put_dispatch(glamor_priv);
 }
 
@@ -174,11 +173,10 @@ void
 glamor_fini_solid_shader(ScreenPtr screen)
 {
     glamor_screen_private *glamor_priv;
-    glamor_gl_dispatch *dispatch;
 
     glamor_priv = glamor_get_screen_private(screen);
-    dispatch = glamor_get_dispatch(glamor_priv);
-    dispatch->glDeleteProgram(glamor_priv->solid_prog);
+    glamor_get_dispatch(glamor_priv);
+    glDeleteProgram(glamor_priv->solid_prog);
     glamor_put_dispatch(glamor_priv);
 }
 
@@ -188,7 +186,6 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
     ScreenPtr screen = pixmap->drawable.pScreen;
     glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
     glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
-    glamor_gl_dispatch *dispatch;
     GLfloat xscale, yscale;
     float vertices[32];
     float *pvertices = vertices;
@@ -196,10 +193,10 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
 
     glamor_set_destination_pixmap_priv_nc(pixmap_priv);
 
-    dispatch = glamor_get_dispatch(glamor_priv);
-    dispatch->glUseProgram(glamor_priv->solid_prog);
+    glamor_get_dispatch(glamor_priv);
+    glUseProgram(glamor_priv->solid_prog);
 
-    dispatch->glUniform4fv(glamor_priv->solid_color_uniform_location, 1, color);
+    glUniform4fv(glamor_priv->solid_color_uniform_location, 1, color);
 
     pixmap_priv_get_dest_scale(pixmap_priv, &xscale, &yscale);
 
@@ -221,11 +218,11 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
     }
 
     if (_X_UNLIKELY(nbox > 1))
-        dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glamor_priv->ebo);
+        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glamor_priv->ebo);
 
-    dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
-                                    GL_FALSE, 2 * sizeof(float), pvertices);
-    dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+    glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
+                          GL_FALSE, 2 * sizeof(float), pvertices);
+    glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
 
     while (nbox) {
         int box_cnt, i;
@@ -242,16 +239,13 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
             valid_vertices += 4 * 2;
         }
         if (box_cnt == 1)
-            dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, box_cnt * 4);
+            glDrawArrays(GL_TRIANGLE_FAN, 0, box_cnt * 4);
         else
 #ifndef GLAMOR_GLES2
-            dispatch->glDrawRangeElements(GL_TRIANGLES,
-                                          0,
-                                          box_cnt * 4,
-                                          box_cnt * 6, GL_UNSIGNED_SHORT, NULL);
+            glDrawRangeElements(GL_TRIANGLES, 0, box_cnt * 4, box_cnt * 6,
+                                GL_UNSIGNED_SHORT, NULL);
 #else
-            dispatch->glDrawElements(GL_TRIANGLES,
-                                     box_cnt * 6, GL_UNSIGNED_SHORT, NULL);
+            glDrawElements(GL_TRIANGLES, box_cnt * 6, GL_UNSIGNED_SHORT, NULL);
 #endif
         nbox -= box_cnt;
         box += box_cnt;
@@ -260,8 +254,8 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
     if (pvertices != vertices)
         free(pvertices);
 
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
-    dispatch->glUseProgram(0);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+    glUseProgram(0);
     glamor_put_dispatch(glamor_priv);
     glamor_priv->state = RENDER_STATE;
     glamor_priv->render_idle_cnt = 0;
@@ -321,7 +315,6 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
     ScreenPtr screen = pixmap->drawable.pScreen;
     glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
     glamor_pixmap_private *pixmap_priv;
-    glamor_gl_dispatch *dispatch;
     BoxRec box;
 
     pixmap_priv = glamor_get_pixmap_private(pixmap);
@@ -334,8 +327,8 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
         return FALSE;
     }
 
-    dispatch = glamor_get_dispatch(glamor_priv);
-    if (!glamor_set_alu(dispatch, alu)) {
+    glamor_get_dispatch(glamor_priv);
+    if (!glamor_set_alu(alu)) {
         if (alu == GXclear)
             fg_pixel = 0;
         else {
@@ -350,7 +343,7 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
     box.y2 = y + height;
     glamor_solid_boxes(pixmap, &box, 1, fg_pixel);
 
-    glamor_set_alu(dispatch, GXcopy);
+    glamor_set_alu(GXcopy);
     glamor_put_dispatch(glamor_priv);
 
     return TRUE;
diff --git a/glamor/glamor_gl_dispatch.c b/glamor/glamor_gl_dispatch.c
deleted file mode 100644
index 0bdda9c..0000000
--- a/glamor/glamor_gl_dispatch.c
+++ /dev/null
@@ -1,118 +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 gmail.com>
- *
- */
-
-#include "glamor_priv.h"
-#include <dlfcn.h>
-
-#define INIT_FUNC(dst,func_name,get)			\
-  dst->func_name = get(#func_name);			\
-  if (dst->func_name == NULL) {				\
-    dst->func_name = (void *)dlsym(NULL, #func_name);	\
-    if (dst->func_name == NULL) {			\
-      ErrorF("Failed to get function %s\n", #func_name);\
-      goto fail;					\
-    }							\
-  }							\
-
-_X_EXPORT Bool
-glamor_gl_dispatch_init_impl(struct glamor_gl_dispatch *dispatch,
-                             int gl_version,
-                             void *(*get_proc_address) (const char *))
-{
-#ifndef GLAMOR_GLES2
-    INIT_FUNC(dispatch, glMatrixMode, get_proc_address);
-    INIT_FUNC(dispatch, glLoadIdentity, get_proc_address);
-    INIT_FUNC(dispatch, glRasterPos2i, get_proc_address);
-    INIT_FUNC(dispatch, glDrawPixels, get_proc_address);
-    INIT_FUNC(dispatch, glLogicOp, get_proc_address);
-    INIT_FUNC(dispatch, glMapBuffer, get_proc_address);
-    INIT_FUNC(dispatch, glMapBufferRange, get_proc_address);
-    INIT_FUNC(dispatch, glUnmapBuffer, get_proc_address);
-    INIT_FUNC(dispatch, glBlitFramebuffer, get_proc_address);
-    INIT_FUNC(dispatch, glDrawRangeElements, get_proc_address);
-#endif
-    INIT_FUNC(dispatch, glViewport, get_proc_address);
-    INIT_FUNC(dispatch, glDrawArrays, get_proc_address);
-    INIT_FUNC(dispatch, glDrawElements, get_proc_address);
-    INIT_FUNC(dispatch, glReadPixels, get_proc_address);
-    INIT_FUNC(dispatch, glPixelStorei, get_proc_address);
-    INIT_FUNC(dispatch, glTexParameteri, get_proc_address);
-    INIT_FUNC(dispatch, glTexImage2D, get_proc_address);
-    INIT_FUNC(dispatch, glGenTextures, get_proc_address);
-    INIT_FUNC(dispatch, glDeleteTextures, get_proc_address);
-    INIT_FUNC(dispatch, glBindTexture, get_proc_address);
-    INIT_FUNC(dispatch, glTexSubImage2D, get_proc_address);
-    INIT_FUNC(dispatch, glFlush, get_proc_address);
-    INIT_FUNC(dispatch, glFinish, get_proc_address);
-    INIT_FUNC(dispatch, glGetIntegerv, get_proc_address);
-    INIT_FUNC(dispatch, glGetString, get_proc_address);
-    INIT_FUNC(dispatch, glScissor, get_proc_address);
-    INIT_FUNC(dispatch, glEnable, get_proc_address);
-    INIT_FUNC(dispatch, glDisable, get_proc_address);
-    INIT_FUNC(dispatch, glBlendFunc, get_proc_address);
-    INIT_FUNC(dispatch, glActiveTexture, get_proc_address);
-    INIT_FUNC(dispatch, glGenBuffers, get_proc_address);
-    INIT_FUNC(dispatch, glBufferData, get_proc_address);
-    INIT_FUNC(dispatch, glBindBuffer, get_proc_address);
-    INIT_FUNC(dispatch, glDeleteBuffers, get_proc_address);
-    INIT_FUNC(dispatch, glFramebufferTexture2D, get_proc_address);
-    INIT_FUNC(dispatch, glBindFramebuffer, get_proc_address);
-    INIT_FUNC(dispatch, glDeleteFramebuffers, get_proc_address);
-    INIT_FUNC(dispatch, glGenFramebuffers, get_proc_address);
-    INIT_FUNC(dispatch, glCheckFramebufferStatus, get_proc_address);
-    INIT_FUNC(dispatch, glVertexAttribPointer, get_proc_address);
-    INIT_FUNC(dispatch, glDisableVertexAttribArray, get_proc_address);
-    INIT_FUNC(dispatch, glEnableVertexAttribArray, get_proc_address);
-    INIT_FUNC(dispatch, glBindAttribLocation, get_proc_address);
-    INIT_FUNC(dispatch, glLinkProgram, get_proc_address);
-    INIT_FUNC(dispatch, glShaderSource, get_proc_address);
-
-    INIT_FUNC(dispatch, glUseProgram, get_proc_address);
-    INIT_FUNC(dispatch, glUniform1i, get_proc_address);
-    INIT_FUNC(dispatch, glUniform1f, get_proc_address);
-    INIT_FUNC(dispatch, glUniform4f, get_proc_address);
-    INIT_FUNC(dispatch, glUniform4fv, get_proc_address);
-    INIT_FUNC(dispatch, glUniform1fv, get_proc_address);
-    INIT_FUNC(dispatch, glUniform2fv, get_proc_address);
-    INIT_FUNC(dispatch, glUniformMatrix3fv, get_proc_address);
-    INIT_FUNC(dispatch, glCreateProgram, get_proc_address);
-    INIT_FUNC(dispatch, glDeleteProgram, get_proc_address);
-    INIT_FUNC(dispatch, glCreateShader, get_proc_address);
-    INIT_FUNC(dispatch, glCompileShader, get_proc_address);
-    INIT_FUNC(dispatch, glAttachShader, get_proc_address);
-    INIT_FUNC(dispatch, glDeleteShader, get_proc_address);
-    INIT_FUNC(dispatch, glGetShaderiv, get_proc_address);
-    INIT_FUNC(dispatch, glGetShaderInfoLog, get_proc_address);
-    INIT_FUNC(dispatch, glGetProgramiv, get_proc_address);
-    INIT_FUNC(dispatch, glGetProgramInfoLog, get_proc_address);
-    INIT_FUNC(dispatch, glGetUniformLocation, get_proc_address);
-
-    return TRUE;
- fail:
-    return FALSE;
-}
diff --git a/glamor/glamor_gl_dispatch.h b/glamor/glamor_gl_dispatch.h
deleted file mode 100644
index 63790b4..0000000
--- a/glamor/glamor_gl_dispatch.h
+++ /dev/null
@@ -1,128 +0,0 @@
-typedef struct glamor_gl_dispatch {
-    /* Transformation functions */
-    void (*glMatrixMode) (GLenum mode);
-    void (*glLoadIdentity) (void);
-    void (*glViewport) (GLint x, GLint y, GLsizei width, GLsizei height);
-    /* Drawing functions */
-    void (*glRasterPos2i) (GLint x, GLint y);
-
-    /* Vertex Array */
-    void (*glDrawArrays) (GLenum mode, GLint first, GLsizei count);
-
-    /* Elements Array */
-    void (*glDrawElements) (GLenum mode, GLsizei count, GLenum type,
-                            const GLvoid * indices);
-    void (*glDrawRangeElements) (GLenum mode, GLuint start, GLuint end,
-                                 GLsizei count, GLenum type,
-                                 const GLvoid * indices);
-
-    /* Raster functions */
-    void (*glReadPixels) (GLint x, GLint y,
-                          GLsizei width, GLsizei height,
-                          GLenum format, GLenum type, GLvoid * pixels);
-
-    void (*glDrawPixels) (GLsizei width, GLsizei height,
-                          GLenum format, GLenum type, const GLvoid * pixels);
-    void (*glPixelStorei) (GLenum pname, GLint param);
-    /* Texture Mapping */
-
-    void (*glTexParameteri) (GLenum target, GLenum pname, GLint param);
-    void (*glTexImage2D) (GLenum target, GLint level,
-                          GLint internalFormat,
-                          GLsizei width, GLsizei height,
-                          GLint border, GLenum format, GLenum type,
-                          const GLvoid * pixels);
-    /* 1.1 */
-    void (*glGenTextures) (GLsizei n, GLuint * textures);
-    void (*glDeleteTextures) (GLsizei n, const GLuint * textures);
-    void (*glBindTexture) (GLenum target, GLuint texture);
-    void (*glTexSubImage2D) (GLenum target, GLint level,
-                             GLint xoffset, GLint yoffset,
-                             GLsizei width, GLsizei height,
-                             GLenum format, GLenum type, const GLvoid * pixels);
-    /* MISC */
-    void (*glFlush) (void);
-    void (*glFinish) (void);
-    void (*glGetIntegerv) (GLenum pname, GLint * params);
-    const GLubyte *(*glGetString) (GLenum name);
-    void (*glScissor) (GLint x, GLint y, GLsizei width, GLsizei height);
-    void (*glEnable) (GLenum cap);
-    void (*glDisable) (GLenum cap);
-    void (*glBlendFunc) (GLenum sfactor, GLenum dfactor);
-    void (*glLogicOp) (GLenum opcode);
-
-    /* 1.3 */
-    void (*glActiveTexture) (GLenum texture);
-
-    /* GL Extentions */
-    void (*glGenBuffers) (GLsizei n, GLuint * buffers);
-    void (*glBufferData) (GLenum target, GLsizeiptr size,
-                          const GLvoid * data, GLenum usage);
-    GLvoid *(*glMapBuffer) (GLenum target, GLenum access);
-    GLvoid *(*glMapBufferRange) (GLenum target, GLintptr offset,
-                                 GLsizeiptr length, GLbitfield access);
-     GLboolean(*glUnmapBuffer) (GLenum target);
-    void (*glBindBuffer) (GLenum target, GLuint buffer);
-    void (*glDeleteBuffers) (GLsizei n, const GLuint * buffers);
-
-    void (*glFramebufferTexture2D) (GLenum target, GLenum attachment,
-                                    GLenum textarget, GLuint texture,
-                                    GLint level);
-    void (*glBindFramebuffer) (GLenum target, GLuint framebuffer);
-    void (*glDeleteFramebuffers) (GLsizei n, const GLuint * framebuffers);
-    void (*glGenFramebuffers) (GLsizei n, GLuint * framebuffers);
-     GLenum(*glCheckFramebufferStatus) (GLenum target);
-    void (*glBlitFramebuffer) (GLint srcX0, GLint srcY0, GLint srcX1,
-                               GLint srcY1, GLint dstX0, GLint dstY0,
-                               GLint dstX1, GLint dstY1,
-                               GLbitfield mask, GLenum filter);
-
-    void (*glVertexAttribPointer) (GLuint index, GLint size,
-                                   GLenum type, GLboolean normalized,
-                                   GLsizei stride, const GLvoid * pointer);
-    void (*glDisableVertexAttribArray) (GLuint index);
-    void (*glEnableVertexAttribArray) (GLuint index);
-    void (*glBindAttribLocation) (GLuint program, GLuint index,
-                                  const GLchar * name);
-
-    void (*glLinkProgram) (GLuint program);
-    void (*glShaderSource) (GLuint shader, GLsizei count,
-                            const GLchar * *string, const GLint * length);
-    void (*glUseProgram) (GLuint program);
-    void (*glUniform1i) (GLint location, GLint v0);
-    void (*glUniform1f) (GLint location, GLfloat v0);
-    void (*glUniform4f) (GLint location, GLfloat v0, GLfloat v1,
-                         GLfloat v2, GLfloat v3);
-    void (*glUniform1fv) (GLint location, GLsizei count, const GLfloat * value);
-    void (*glUniform2fv) (GLint location, GLsizei count, const GLfloat * value);
-    void (*glUniform4fv) (GLint location, GLsizei count, const GLfloat * value);
-    void (*glUniformMatrix3fv) (GLint location, GLsizei count,
-                                GLboolean transpose, const GLfloat * value);
-     GLuint(*glCreateProgram) (void);
-     GLuint(*glDeleteProgram) (GLuint);
-     GLuint(*glCreateShader) (GLenum type);
-    void (*glCompileShader) (GLuint shader);
-    void (*glAttachShader) (GLuint program, GLuint shader);
-    void (*glDeleteShader) (GLuint shader);
-    void (*glGetShaderiv) (GLuint shader, GLenum pname, GLint * params);
-    void (*glGetShaderInfoLog) (GLuint shader, GLsizei bufSize,
-                                GLsizei * length, GLchar * infoLog);
-    void (*glGetProgramiv) (GLuint program, GLenum pname, GLint * params);
-    void (*glGetProgramInfoLog) (GLuint program, GLsizei bufSize,
-                                 GLsizei * length, GLchar * infoLog);
-     GLint(*glGetUniformLocation) (GLuint program, const GLchar * name);
-
-} glamor_gl_dispatch;
-
-typedef void *(*get_proc_address_t) (const char *);
-
-_X_EXPORT Bool
-
-glamor_gl_dispatch_init_impl(struct glamor_gl_dispatch *dispatch,
-                             int gl_version,
-                             get_proc_address_t get_proc_address);
-
-_X_EXPORT Bool
-
-glamor_gl_dispatch_init(ScreenPtr screen,
-                        struct glamor_gl_dispatch *dispatch, int gl_version);
diff --git a/glamor/glamor_glext.h b/glamor/glamor_glext.h
deleted file mode 100644
index 2a220c3..0000000
--- a/glamor/glamor_glext.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright © 2001 Keith Packard
- * Copyright © 2008 Intel Corporation
- *
- * 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>
- *
- */
-
-#ifdef GLAMOR_GLES2
-
-#define GL_BGRA                                 GL_BGRA_EXT
-#define GL_COLOR_INDEX                          0x1900
-#define GL_BITMAP                               0x1A00
-#define GL_UNSIGNED_INT_8_8_8_8                 0x8035
-#define GL_UNSIGNED_INT_8_8_8_8_REV             0x8367
-#define GL_UNSIGNED_INT_2_10_10_10_REV          0x8368
-#define GL_UNSIGNED_INT_10_10_10_2              0x8036
-#define GL_UNSIGNED_SHORT_5_6_5_REV             0x8364
-#define GL_UNSIGNED_SHORT_1_5_5_5_REV           0x8366
-#define GL_UNSIGNED_SHORT_4_4_4_4_REV           0x8365
-
-#define GL_PIXEL_PACK_BUFFER              0x88EB
-#define GL_PIXEL_UNPACK_BUFFER            0x88EC
-#define GL_CLAMP_TO_BORDER                0x812D
-
-#define GL_READ_WRITE                     0x88BA
-#define GL_READ_ONLY                      0x88B8
-#define GL_WRITE_ONLY                     0x88B9
-#define GL_STREAM_DRAW                    0x88E0
-#define GL_STREAM_READ                    0x88E1
-#define GL_PACK_ROW_LENGTH                      0x0D02
-#define GL_UNPACK_ROW_LENGTH                    0x0CF2
-
-#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB
-#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56
-
-#define GL_PACK_INVERT_MESA               0x8758
-#define GL_MAP_UNSYNCHRONIZED_BIT         0x0020
-#define GL_MAP_READ_BIT                   0x0001
-#define GL_MAP_WRITE_BIT                  0x0002
-
-#endif
diff --git a/glamor/glamor_glyphs.c b/glamor/glamor_glyphs.c
index 3586b33..c118f34 100644
--- a/glamor/glamor_glyphs.c
+++ b/glamor/glamor_glyphs.c
@@ -1274,14 +1274,12 @@ glamor_buffer_glyph(glamor_screen_private *glamor_priv,
             if (buffer->source == NULL)
                 buffer->source = source;
             if (glyphs_dst_mode == GLYPHS_DST_MODE_VIA_MASK_CACHE) {
-                glamor_gl_dispatch *dispatch;
-
                 /* mode 1 means we are using global mask cache,
                  * thus we have to composite from the cache picture
                  * to the cache picture, we need a flush here to make
                  * sure latter we get the corret glyphs data.*/
-                dispatch = glamor_get_dispatch(glamor_priv);
-                dispatch->glFlush();
+                glamor_get_dispatch(glamor_priv);
+                glFlush();
                 glamor_put_dispatch(glamor_priv);
             }
         }
diff --git a/glamor/glamor_gradient.c b/glamor/glamor_gradient.c
index df2ccb8..08df996 100644
--- a/glamor/glamor_gradient.c
+++ b/glamor/glamor_gradient.c
@@ -47,7 +47,6 @@ _glamor_create_getcolor_fs_program(ScreenPtr screen, int stops_count,
                                    int use_array)
 {
     glamor_screen_private *glamor_priv;
-    glamor_gl_dispatch *dispatch;
 
     char *gradient_fs = NULL;
     GLint fs_getcolor_prog;
@@ -177,18 +176,18 @@ _glamor_create_getcolor_fs_program(ScreenPtr screen, int stops_count,
         "}\n";
 
     glamor_priv = glamor_get_screen_private(screen);
-    dispatch = glamor_get_dispatch(glamor_priv);
+    glamor_get_dispatch(glamor_priv);
 
     if (use_array) {
         XNFasprintf(&gradient_fs,
                     gradient_fs_getcolor, stops_count, stops_count);
         fs_getcolor_prog =
-            glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER, gradient_fs);
+            glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, gradient_fs);
         free(gradient_fs);
     }
     else {
         fs_getcolor_prog =
-            glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
+            glamor_compile_glsl_prog(GL_FRAGMENT_SHADER,
                                      gradient_fs_getcolor_no_array);
     }
 
@@ -200,7 +199,6 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, int stops_count,
                                        int dyn_gen)
 {
     glamor_screen_private *glamor_priv;
-    glamor_gl_dispatch *dispatch;
     int index;
 
     GLint gradient_prog = 0;
@@ -355,42 +353,37 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, int stops_count,
         return;
     }
 
-    dispatch = glamor_get_dispatch(glamor_priv);
+    glamor_get_dispatch(glamor_priv);
 
     if (dyn_gen && glamor_priv->gradient_prog[SHADER_GRADIENT_RADIAL][2]) {
-        dispatch->glDeleteShader(glamor_priv->
-                                 radial_gradient_shaders
-                                 [SHADER_GRADIENT_VS_PROG][2]);
+        glDeleteShader(glamor_priv->radial_gradient_shaders
+                       [SHADER_GRADIENT_VS_PROG][2]);
         glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_VS_PROG][2] = 0;
 
-        dispatch->glDeleteShader(glamor_priv->
-                                 radial_gradient_shaders
-                                 [SHADER_GRADIENT_FS_MAIN_PROG][2]);
+        glDeleteShader(glamor_priv->radial_gradient_shaders
+                       [SHADER_GRADIENT_FS_MAIN_PROG][2]);
         glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][2] =
             0;
 
-        dispatch->glDeleteShader(glamor_priv->
-                                 radial_gradient_shaders
-                                 [SHADER_GRADIENT_FS_GETCOLOR_PROG][2]);
+        glDeleteShader(glamor_priv->radial_gradient_shaders
+                       [SHADER_GRADIENT_FS_GETCOLOR_PROG][2]);
         glamor_priv->
             radial_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][2] = 0;
 
-        dispatch->glDeleteProgram(glamor_priv->
-                                  gradient_prog[SHADER_GRADIENT_RADIAL][2]);
+        glDeleteProgram(glamor_priv->gradient_prog[SHADER_GRADIENT_RADIAL][2]);
         glamor_priv->gradient_prog[SHADER_GRADIENT_RADIAL][2] = 0;
     }
 
-    gradient_prog = dispatch->glCreateProgram();
+    gradient_prog = glCreateProgram();
 
-    vs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, gradient_vs);
+    vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, gradient_vs);
 
     XNFasprintf(&gradient_fs,
                 gradient_radial_fs_template,
                 PIXMAN_REPEAT_NONE, PIXMAN_REPEAT_NORMAL,
                 PIXMAN_REPEAT_REFLECT);
 
-    fs_main_prog = glamor_compile_glsl_prog(dispatch,
-                                            GL_FRAGMENT_SHADER, gradient_fs);
+    fs_main_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, gradient_fs);
 
     free(gradient_fs);
 
@@ -398,18 +391,16 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, int stops_count,
         _glamor_create_getcolor_fs_program(screen, stops_count,
                                            (stops_count > 0));
 
-    dispatch->glAttachShader(gradient_prog, vs_prog);
-    dispatch->glAttachShader(gradient_prog, fs_getcolor_prog);
-    dispatch->glAttachShader(gradient_prog, fs_main_prog);
+    glAttachShader(gradient_prog, vs_prog);
+    glAttachShader(gradient_prog, fs_getcolor_prog);
+    glAttachShader(gradient_prog, fs_main_prog);
 
-    dispatch->glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_POS,
-                                   "v_positionsition");
-    dispatch->glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_SOURCE,
-                                   "v_texcoord");
+    glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_POS, "v_positionsition");
+    glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_SOURCE, "v_texcoord");
 
-    glamor_link_glsl_prog(dispatch, gradient_prog);
+    glamor_link_glsl_prog(gradient_prog);
 
-    dispatch->glUseProgram(0);
+    glUseProgram(0);
 
     if (dyn_gen) {
         index = 2;
@@ -439,7 +430,6 @@ _glamor_create_linear_gradient_program(ScreenPtr screen, int stops_count,
                                        int dyn_gen)
 {
     glamor_screen_private *glamor_priv;
-    glamor_gl_dispatch *dispatch;
 
     int index = 0;
     GLint gradient_prog = 0;
@@ -596,58 +586,51 @@ _glamor_create_linear_gradient_program(ScreenPtr screen, int stops_count,
         return;
     }
 
-    dispatch = glamor_get_dispatch(glamor_priv);
+    glamor_get_dispatch(glamor_priv);
     if (dyn_gen && glamor_priv->gradient_prog[SHADER_GRADIENT_LINEAR][2]) {
-        dispatch->glDeleteShader(glamor_priv->
-                                 linear_gradient_shaders
-                                 [SHADER_GRADIENT_VS_PROG][2]);
+        glDeleteShader(glamor_priv->linear_gradient_shaders
+                       [SHADER_GRADIENT_VS_PROG][2]);
         glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_VS_PROG][2] = 0;
 
-        dispatch->glDeleteShader(glamor_priv->
-                                 linear_gradient_shaders
-                                 [SHADER_GRADIENT_FS_MAIN_PROG][2]);
+        glDeleteShader(glamor_priv->linear_gradient_shaders
+                       [SHADER_GRADIENT_FS_MAIN_PROG][2]);
         glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][2] =
             0;
 
-        dispatch->glDeleteShader(glamor_priv->
-                                 linear_gradient_shaders
-                                 [SHADER_GRADIENT_FS_GETCOLOR_PROG][2]);
+        glDeleteShader(glamor_priv->linear_gradient_shaders
+                       [SHADER_GRADIENT_FS_GETCOLOR_PROG][2]);
         glamor_priv->
             linear_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][2] = 0;
 
-        dispatch->glDeleteProgram(glamor_priv->
-                                  gradient_prog[SHADER_GRADIENT_LINEAR][2]);
+        glDeleteProgram(glamor_priv->gradient_prog[SHADER_GRADIENT_LINEAR][2]);
         glamor_priv->gradient_prog[SHADER_GRADIENT_LINEAR][2] = 0;
     }
 
-    gradient_prog = dispatch->glCreateProgram();
+    gradient_prog = glCreateProgram();
 
-    vs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, gradient_vs);
+    vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, gradient_vs);
 
     XNFasprintf(&gradient_fs,
                 gradient_fs_template,
                 PIXMAN_REPEAT_NORMAL, PIXMAN_REPEAT_REFLECT);
 
-    fs_main_prog = glamor_compile_glsl_prog(dispatch,
-                                            GL_FRAGMENT_SHADER, gradient_fs);
+    fs_main_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, gradient_fs);
     free(gradient_fs);
 
     fs_getcolor_prog =
         _glamor_create_getcolor_fs_program(screen, stops_count,
                                            (stops_count > 0));
 
-    dispatch->glAttachShader(gradient_prog, vs_prog);
-    dispatch->glAttachShader(gradient_prog, fs_getcolor_prog);
-    dispatch->glAttachShader(gradient_prog, fs_main_prog);
+    glAttachShader(gradient_prog, vs_prog);
+    glAttachShader(gradient_prog, fs_getcolor_prog);
+    glAttachShader(gradient_prog, fs_main_prog);
 
-    dispatch->glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_POS,
-                                   "v_position");
-    dispatch->glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_SOURCE,
-                                   "v_texcoord");
+    glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_POS, "v_position");
+    glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_SOURCE, "v_texcoord");
 
-    glamor_link_glsl_prog(dispatch, gradient_prog);
+    glamor_link_glsl_prog(gradient_prog);
 
-    dispatch->glUseProgram(0);
+    glUseProgram(0);
 
     if (dyn_gen) {
         index = 2;
@@ -709,56 +692,49 @@ void
 glamor_fini_gradient_shader(ScreenPtr screen)
 {
     glamor_screen_private *glamor_priv;
-    glamor_gl_dispatch *dispatch;
     int i = 0;
 
     glamor_priv = glamor_get_screen_private(screen);
-    dispatch = glamor_get_dispatch(glamor_priv);
+    glamor_get_dispatch(glamor_priv);
 
     for (i = 0; i < 3; i++) {
         /* Linear Gradient */
         if (glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_VS_PROG][i])
-            dispatch->glDeleteShader(glamor_priv->
-                                     linear_gradient_shaders
-                                     [SHADER_GRADIENT_VS_PROG][i]);
+            glDeleteShader(glamor_priv->linear_gradient_shaders
+                           [SHADER_GRADIENT_VS_PROG][i]);
 
         if (glamor_priv->
             linear_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][i])
-            dispatch->glDeleteShader(glamor_priv->
-                                     linear_gradient_shaders
-                                     [SHADER_GRADIENT_FS_MAIN_PROG][i]);
+            glDeleteShader(glamor_priv->linear_gradient_shaders
+                           [SHADER_GRADIENT_FS_MAIN_PROG][i]);
 
         if (glamor_priv->
             linear_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][i])
-            dispatch->glDeleteShader(glamor_priv->
-                                     linear_gradient_shaders
-                                     [SHADER_GRADIENT_FS_GETCOLOR_PROG][i]);
+            glDeleteShader(glamor_priv->linear_gradient_shaders
+                           [SHADER_GRADIENT_FS_GETCOLOR_PROG][i]);
 
         if (glamor_priv->gradient_prog[SHADER_GRADIENT_LINEAR][i])
-            dispatch->glDeleteProgram(glamor_priv->
-                                      gradient_prog[SHADER_GRADIENT_LINEAR][i]);
+            glDeleteProgram(glamor_priv->gradient_prog
+                            [SHADER_GRADIENT_LINEAR][i]);
 
         /* Radial Gradient */
         if (glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_VS_PROG][i])
-            dispatch->glDeleteShader(glamor_priv->
-                                     radial_gradient_shaders
-                                     [SHADER_GRADIENT_VS_PROG][i]);
+            glDeleteShader(glamor_priv->radial_gradient_shaders
+                           [SHADER_GRADIENT_VS_PROG][i]);
 
         if (glamor_priv->
             radial_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][i])
-            dispatch->glDeleteShader(glamor_priv->
-                                     radial_gradient_shaders
-                                     [SHADER_GRADIENT_FS_MAIN_PROG][i]);
+            glDeleteShader(glamor_priv->radial_gradient_shaders
+                           [SHADER_GRADIENT_FS_MAIN_PROG][i]);
 
         if (glamor_priv->
             radial_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][i])
-            dispatch->glDeleteShader(glamor_priv->
-                                     radial_gradient_shaders
-                                     [SHADER_GRADIENT_FS_GETCOLOR_PROG][i]);
+            glDeleteShader(glamor_priv->radial_gradient_shaders
+                           [SHADER_GRADIENT_FS_GETCOLOR_PROG][i]);
 
         if (glamor_priv->gradient_prog[SHADER_GRADIENT_RADIAL][i])
-            dispatch->glDeleteProgram(glamor_priv->
-                                      gradient_prog[SHADER_GRADIENT_RADIAL][i]);
+            glDeleteProgram(glamor_priv->gradient_prog
+                            [SHADER_GRADIENT_RADIAL][i]);
     }
 
     glamor_put_dispatch(glamor_priv);
@@ -835,7 +811,6 @@ _glamor_gradient_set_pixmap_destination(ScreenPtr screen,
 {
     glamor_pixmap_private *pixmap_priv;
     PixmapPtr pixmap = NULL;
-    glamor_gl_dispatch *dispatch = NULL;
 
     pixmap = glamor_get_drawable_pixmap(dst_picture->pDrawable);
     pixmap_priv = glamor_get_pixmap_private(pixmap);
@@ -893,15 +868,15 @@ _glamor_gradient_set_pixmap_destination(ScreenPtr screen,
            tex_vertices[0], tex_vertices[1], tex_vertices[2], tex_vertices[3],
            tex_vertices[4], tex_vertices[5], tex_vertices[6], tex_vertices[7]);
 
-    dispatch = glamor_get_dispatch(glamor_priv);
+    glamor_get_dispatch(glamor_priv);
 
-    dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
-                                    GL_FALSE, 0, vertices);
-    dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT,
-                                    GL_FALSE, 0, tex_vertices);
+    glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
+                          GL_FALSE, 0, vertices);
+    glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT,
+                          GL_FALSE, 0, tex_vertices);
 
-    dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
-    dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+    glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+    glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
 
     glamor_put_dispatch(glamor_priv);
 
@@ -996,7 +971,6 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
                                         PictFormatShort format)
 {
     glamor_screen_private *glamor_priv;
-    glamor_gl_dispatch *dispatch;
     PicturePtr dst_picture = NULL;
     PixmapPtr pixmap = NULL;
     GLint gradient_prog = 0;
@@ -1047,7 +1021,7 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
     GLint r2_uniform_location = 0;
 
     glamor_priv = glamor_get_screen_private(screen);
-    dispatch = glamor_get_dispatch(glamor_priv);
+    glamor_get_dispatch(glamor_priv);
 
     /* Create a pixmap with VBO. */
     pixmap = glamor_create_pixmap(screen,
@@ -1088,77 +1062,74 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
     }
 
     /* Bind all the uniform vars . */
-    transform_mat_uniform_location =
-        dispatch->glGetUniformLocation(gradient_prog, "transform_mat");
-    repeat_type_uniform_location =
-        dispatch->glGetUniformLocation(gradient_prog, "repeat_type");
-    n_stop_uniform_location =
-        dispatch->glGetUniformLocation(gradient_prog, "n_stop");
-    A_value_uniform_location =
-        dispatch->glGetUniformLocation(gradient_prog, "A_value");
-    repeat_type_uniform_location =
-        dispatch->glGetUniformLocation(gradient_prog, "repeat_type");
-    c1_uniform_location = dispatch->glGetUniformLocation(gradient_prog, "c1");
-    r1_uniform_location = dispatch->glGetUniformLocation(gradient_prog, "r1");
-    c2_uniform_location = dispatch->glGetUniformLocation(gradient_prog, "c2");
-    r2_uniform_location = dispatch->glGetUniformLocation(gradient_prog, "r2");
+    transform_mat_uniform_location = glGetUniformLocation(gradient_prog,
+                                                          "transform_mat");
+    repeat_type_uniform_location = glGetUniformLocation(gradient_prog,
+                                                        "repeat_type");
+    n_stop_uniform_location = glGetUniformLocation(gradient_prog, "n_stop");
+    A_value_uniform_location = glGetUniformLocation(gradient_prog, "A_value");
+    repeat_type_uniform_location =glGetUniformLocation(gradient_prog,
+                                                       "repeat_type");
+    c1_uniform_location = glGetUniformLocation(gradient_prog, "c1");
+    r1_uniform_location = glGetUniformLocation(gradient_prog, "r1");
+    c2_uniform_location = glGetUniformLocation(gradient_prog, "c2");
+    r2_uniform_location = glGetUniformLocation(gradient_prog, "r2");
 
     if (src_picture->pSourcePict->radial.nstops + 2 <= RADIAL_SMALL_STOPS) {
         stop0_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop0");
+            glGetUniformLocation(gradient_prog, "stop0");
         stop1_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop1");
+            glGetUniformLocation(gradient_prog, "stop1");
         stop2_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop2");
+            glGetUniformLocation(gradient_prog, "stop2");
         stop3_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop3");
+            glGetUniformLocation(gradient_prog, "stop3");
         stop4_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop4");
+            glGetUniformLocation(gradient_prog, "stop4");
         stop5_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop5");
+            glGetUniformLocation(gradient_prog, "stop5");
         stop6_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop6");
+            glGetUniformLocation(gradient_prog, "stop6");
         stop7_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop7");
+            glGetUniformLocation(gradient_prog, "stop7");
 
         stop_color0_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop_color0");
+            glGetUniformLocation(gradient_prog, "stop_color0");
         stop_color1_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop_color1");
+            glGetUniformLocation(gradient_prog, "stop_color1");
         stop_color2_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop_color2");
+            glGetUniformLocation(gradient_prog, "stop_color2");
         stop_color3_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop_color3");
+            glGetUniformLocation(gradient_prog, "stop_color3");
         stop_color4_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop_color4");
+            glGetUniformLocation(gradient_prog, "stop_color4");
         stop_color5_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop_color5");
+            glGetUniformLocation(gradient_prog, "stop_color5");
         stop_color6_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop_color6");
+            glGetUniformLocation(gradient_prog, "stop_color6");
         stop_color7_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop_color7");
+            glGetUniformLocation(gradient_prog, "stop_color7");
     }
     else {
         stops_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stops");
+            glGetUniformLocation(gradient_prog, "stops");
         stop_colors_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop_colors");
+            glGetUniformLocation(gradient_prog, "stop_colors");
     }
 
-    dispatch->glUseProgram(gradient_prog);
+    glUseProgram(gradient_prog);
 
-    dispatch->glUniform1i(repeat_type_uniform_location,
-                          src_picture->repeatType);
+    glUniform1i(repeat_type_uniform_location, src_picture->repeatType);
 
     if (src_picture->transform) {
         _glamor_gradient_convert_trans_matrix(src_picture->transform,
                                               transform_mat, width, height, 0);
-        dispatch->glUniformMatrix3fv(transform_mat_uniform_location,
-                                     1, 1, &transform_mat[0][0]);
+        glUniformMatrix3fv(transform_mat_uniform_location,
+                           1, 1, &transform_mat[0][0]);
     }
     else {
-        dispatch->glUniformMatrix3fv(transform_mat_uniform_location,
-                                     1, 1, &identity_mat[0][0]);
+        glUniformMatrix3fv(transform_mat_uniform_location,
+                           1, 1, &identity_mat[0][0]);
     }
 
     if (!_glamor_gradient_set_pixmap_destination
@@ -1193,54 +1164,53 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
     if (src_picture->pSourcePict->linear.nstops + 2 <= RADIAL_SMALL_STOPS) {
         int j = 0;
 
-        dispatch->glUniform4f(stop_color0_uniform_location,
-                              stop_colors[4 * j + 0], stop_colors[4 * j + 1],
-                              stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
+        glUniform4f(stop_color0_uniform_location,
+                    stop_colors[4 * j + 0], stop_colors[4 * j + 1],
+                    stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
         j++;
-        dispatch->glUniform4f(stop_color1_uniform_location,
-                              stop_colors[4 * j + 0], stop_colors[4 * j + 1],
-                              stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
+        glUniform4f(stop_color1_uniform_location,
+                    stop_colors[4 * j + 0], stop_colors[4 * j + 1],
+                    stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
         j++;
-        dispatch->glUniform4f(stop_color2_uniform_location,
-                              stop_colors[4 * j + 0], stop_colors[4 * j + 1],
-                              stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
+        glUniform4f(stop_color2_uniform_location,
+                    stop_colors[4 * j + 0], stop_colors[4 * j + 1],
+                    stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
         j++;
-        dispatch->glUniform4f(stop_color3_uniform_location,
-                              stop_colors[4 * j + 0], stop_colors[4 * j + 1],
-                              stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
+        glUniform4f(stop_color3_uniform_location,
+                    stop_colors[4 * j + 0], stop_colors[4 * j + 1],
+                    stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
         j++;
-        dispatch->glUniform4f(stop_color4_uniform_location,
-                              stop_colors[4 * j + 0], stop_colors[4 * j + 1],
-                              stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
+        glUniform4f(stop_color4_uniform_location,
+                    stop_colors[4 * j + 0], stop_colors[4 * j + 1],
+                    stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
         j++;
-        dispatch->glUniform4f(stop_color5_uniform_location,
-                              stop_colors[4 * j + 0], stop_colors[4 * j + 1],
-                              stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
+        glUniform4f(stop_color5_uniform_location,
+                    stop_colors[4 * j + 0], stop_colors[4 * j + 1],
+                    stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
         j++;
-        dispatch->glUniform4f(stop_color6_uniform_location,
-                              stop_colors[4 * j + 0], stop_colors[4 * j + 1],
-                              stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
+        glUniform4f(stop_color6_uniform_location,
+                    stop_colors[4 * j + 0], stop_colors[4 * j + 1],
+                    stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
         j++;
-        dispatch->glUniform4f(stop_color7_uniform_location,
-                              stop_colors[4 * j + 0], stop_colors[4 * j + 1],
-                              stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
+        glUniform4f(stop_color7_uniform_location,
+                    stop_colors[4 * j + 0], stop_colors[4 * j + 1],
+                    stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
 
         j = 0;
-        dispatch->glUniform1f(stop0_uniform_location, n_stops[j++]);
-        dispatch->glUniform1f(stop1_uniform_location, n_stops[j++]);
-        dispatch->glUniform1f(stop2_uniform_location, n_stops[j++]);
-        dispatch->glUniform1f(stop3_uniform_location, n_stops[j++]);
-        dispatch->glUniform1f(stop4_uniform_location, n_stops[j++]);
-        dispatch->glUniform1f(stop5_uniform_location, n_stops[j++]);
-        dispatch->glUniform1f(stop6_uniform_location, n_stops[j++]);
-        dispatch->glUniform1f(stop7_uniform_location, n_stops[j++]);
-        dispatch->glUniform1i(n_stop_uniform_location, count);
+        glUniform1f(stop0_uniform_location, n_stops[j++]);
+        glUniform1f(stop1_uniform_location, n_stops[j++]);
+        glUniform1f(stop2_uniform_location, n_stops[j++]);
+        glUniform1f(stop3_uniform_location, n_stops[j++]);
+        glUniform1f(stop4_uniform_location, n_stops[j++]);
+        glUniform1f(stop5_uniform_location, n_stops[j++]);
+        glUniform1f(stop6_uniform_location, n_stops[j++]);
+        glUniform1f(stop7_uniform_location, n_stops[j++]);
+        glUniform1i(n_stop_uniform_location, count);
     }
     else {
-        dispatch->glUniform4fv(stop_colors_uniform_location, count,
-                               stop_colors);
-        dispatch->glUniform1fv(stops_uniform_location, count, n_stops);
-        dispatch->glUniform1i(n_stop_uniform_location, count);
+        glUniform4fv(stop_colors_uniform_location, count, stop_colors);
+        glUniform1fv(stops_uniform_location, count, n_stops);
+        glUniform1i(n_stop_uniform_location, count);
     }
 
     c1x = (float) pixman_fixed_to_double(src_picture->pSourcePict->radial.c1.x);
@@ -1255,25 +1225,25 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
 
     glamor_set_circle_centre(width, height, c1x, c1y, glamor_priv->yInverted,
                              cxy);
-    dispatch->glUniform2fv(c1_uniform_location, 1, cxy);
-    dispatch->glUniform1f(r1_uniform_location, r1);
+    glUniform2fv(c1_uniform_location, 1, cxy);
+    glUniform1f(r1_uniform_location, r1);
 
     glamor_set_circle_centre(width, height, c2x, c2y, glamor_priv->yInverted,
                              cxy);
-    dispatch->glUniform2fv(c2_uniform_location, 1, cxy);
-    dispatch->glUniform1f(r2_uniform_location, r2);
+    glUniform2fv(c2_uniform_location, 1, cxy);
+    glUniform1f(r2_uniform_location, r2);
 
     A_value =
         (c2x - c1x) * (c2x - c1x) + (c2y - c1y) * (c2y - c1y) - (r2 -
                                                                  r1) * (r2 -
                                                                         r1);
-    dispatch->glUniform1f(A_value_uniform_location, A_value);
+    glUniform1f(A_value_uniform_location, A_value);
 
     DEBUGF("C1:(%f, %f) R1:%f\nC2:(%f, %f) R2:%f\nA = %f\n",
            c1x, c1y, r1, c2x, c2y, r2, A_value);
 
     /* Now rendering. */
-    dispatch->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
 
     /* Do the clear logic. */
     if (stops_count > RADIAL_SMALL_STOPS) {
@@ -1281,12 +1251,12 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
         free(stop_colors);
     }
 
-    dispatch->glBindBuffer(GL_ARRAY_BUFFER, 0);
-    dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+    glBindBuffer(GL_ARRAY_BUFFER, 0);
+    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
 
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
-    dispatch->glUseProgram(0);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+    glUseProgram(0);
 
     glamor_put_dispatch(glamor_priv);
     return dst_picture;
@@ -1303,12 +1273,12 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
             free(stop_colors);
     }
 
-    dispatch->glBindBuffer(GL_ARRAY_BUFFER, 0);
-    dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+    glBindBuffer(GL_ARRAY_BUFFER, 0);
+    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
 
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
-    dispatch->glUseProgram(0);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+    glUseProgram(0);
     glamor_put_dispatch(glamor_priv);
     return NULL;
 }
@@ -1321,7 +1291,6 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
                                         PictFormatShort format)
 {
     glamor_screen_private *glamor_priv;
-    glamor_gl_dispatch *dispatch;
     PicturePtr dst_picture = NULL;
     PixmapPtr pixmap = NULL;
     GLint gradient_prog = 0;
@@ -1374,7 +1343,7 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
     GLint pt_distance_uniform_location = 0;
 
     glamor_priv = glamor_get_screen_private(screen);
-    dispatch = glamor_get_dispatch(glamor_priv);
+    glamor_get_dispatch(glamor_priv);
 
     /* Create a pixmap with VBO. */
     pixmap = glamor_create_pixmap(screen,
@@ -1417,79 +1386,78 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
 
     /* Bind all the uniform vars . */
     n_stop_uniform_location =
-        dispatch->glGetUniformLocation(gradient_prog, "n_stop");
+        glGetUniformLocation(gradient_prog, "n_stop");
     pt_slope_uniform_location =
-        dispatch->glGetUniformLocation(gradient_prog, "pt_slope");
+        glGetUniformLocation(gradient_prog, "pt_slope");
     repeat_type_uniform_location =
-        dispatch->glGetUniformLocation(gradient_prog, "repeat_type");
+        glGetUniformLocation(gradient_prog, "repeat_type");
     hor_ver_uniform_location =
-        dispatch->glGetUniformLocation(gradient_prog, "hor_ver");
+        glGetUniformLocation(gradient_prog, "hor_ver");
     transform_mat_uniform_location =
-        dispatch->glGetUniformLocation(gradient_prog, "transform_mat");
+        glGetUniformLocation(gradient_prog, "transform_mat");
     cos_val_uniform_location =
-        dispatch->glGetUniformLocation(gradient_prog, "cos_val");
+        glGetUniformLocation(gradient_prog, "cos_val");
     p1_distance_uniform_location =
-        dispatch->glGetUniformLocation(gradient_prog, "p1_distance");
+        glGetUniformLocation(gradient_prog, "p1_distance");
     pt_distance_uniform_location =
-        dispatch->glGetUniformLocation(gradient_prog, "pt_distance");
+        glGetUniformLocation(gradient_prog, "pt_distance");
 
     if (src_picture->pSourcePict->linear.nstops + 2 <= LINEAR_SMALL_STOPS) {
         stop0_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop0");
+            glGetUniformLocation(gradient_prog, "stop0");
         stop1_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop1");
+            glGetUniformLocation(gradient_prog, "stop1");
         stop2_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop2");
+            glGetUniformLocation(gradient_prog, "stop2");
         stop3_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop3");
+            glGetUniformLocation(gradient_prog, "stop3");
         stop4_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop4");
+            glGetUniformLocation(gradient_prog, "stop4");
         stop5_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop5");
+            glGetUniformLocation(gradient_prog, "stop5");
         stop6_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop6");
+            glGetUniformLocation(gradient_prog, "stop6");
         stop7_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop7");
+            glGetUniformLocation(gradient_prog, "stop7");
 
         stop_color0_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop_color0");
+            glGetUniformLocation(gradient_prog, "stop_color0");
         stop_color1_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop_color1");
+            glGetUniformLocation(gradient_prog, "stop_color1");
         stop_color2_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop_color2");
+            glGetUniformLocation(gradient_prog, "stop_color2");
         stop_color3_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop_color3");
+            glGetUniformLocation(gradient_prog, "stop_color3");
         stop_color4_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop_color4");
+            glGetUniformLocation(gradient_prog, "stop_color4");
         stop_color5_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop_color5");
+            glGetUniformLocation(gradient_prog, "stop_color5");
         stop_color6_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop_color6");
+            glGetUniformLocation(gradient_prog, "stop_color6");
         stop_color7_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop_color7");
+            glGetUniformLocation(gradient_prog, "stop_color7");
     }
     else {
         stops_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stops");
+            glGetUniformLocation(gradient_prog, "stops");
         stop_colors_uniform_location =
-            dispatch->glGetUniformLocation(gradient_prog, "stop_colors");
+            glGetUniformLocation(gradient_prog, "stop_colors");
     }
 
-    dispatch->glUseProgram(gradient_prog);
+    glUseProgram(gradient_prog);
 
-    dispatch->glUniform1i(repeat_type_uniform_location,
-                          src_picture->repeatType);
+    glUniform1i(repeat_type_uniform_location, src_picture->repeatType);
 
     /* set the transform matrix. */
     if (src_picture->transform) {
         _glamor_gradient_convert_trans_matrix(src_picture->transform,
                                               transform_mat, width, height, 1);
-        dispatch->glUniformMatrix3fv(transform_mat_uniform_location,
-                                     1, 1, &transform_mat[0][0]);
+        glUniformMatrix3fv(transform_mat_uniform_location,
+                           1, 1, &transform_mat[0][0]);
     }
     else {
-        dispatch->glUniformMatrix3fv(transform_mat_uniform_location,
-                                     1, 1, &identity_mat[0][0]);
+        glUniformMatrix3fv(transform_mat_uniform_location,
+                           1, 1, &identity_mat[0][0]);
     }
 
     if (!_glamor_gradient_set_pixmap_destination
@@ -1547,66 +1515,65 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
     if (src_picture->pSourcePict->linear.nstops + 2 <= LINEAR_SMALL_STOPS) {
         int j = 0;
 
-        dispatch->glUniform4f(stop_color0_uniform_location,
-                              stop_colors[4 * j + 0], stop_colors[4 * j + 1],
-                              stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
+        glUniform4f(stop_color0_uniform_location,
+                    stop_colors[4 * j + 0], stop_colors[4 * j + 1],
+                    stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
         j++;
-        dispatch->glUniform4f(stop_color1_uniform_location,
-                              stop_colors[4 * j + 0], stop_colors[4 * j + 1],
-                              stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
+        glUniform4f(stop_color1_uniform_location,
+                    stop_colors[4 * j + 0], stop_colors[4 * j + 1],
+                    stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
         j++;
-        dispatch->glUniform4f(stop_color2_uniform_location,
-                              stop_colors[4 * j + 0], stop_colors[4 * j + 1],
-                              stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
+        glUniform4f(stop_color2_uniform_location,
+                    stop_colors[4 * j + 0], stop_colors[4 * j + 1],
+                    stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
         j++;
-        dispatch->glUniform4f(stop_color3_uniform_location,
-                              stop_colors[4 * j + 0], stop_colors[4 * j + 1],
-                              stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
+        glUniform4f(stop_color3_uniform_location,
+                    stop_colors[4 * j + 0], stop_colors[4 * j + 1],
+                    stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
         j++;
-        dispatch->glUniform4f(stop_color4_uniform_location,
-                              stop_colors[4 * j + 0], stop_colors[4 * j + 1],
-                              stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
+        glUniform4f(stop_color4_uniform_location,
+                    stop_colors[4 * j + 0], stop_colors[4 * j + 1],
+                    stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
         j++;
-        dispatch->glUniform4f(stop_color5_uniform_location,
-                              stop_colors[4 * j + 0], stop_colors[4 * j + 1],
-                              stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
+        glUniform4f(stop_color5_uniform_location,
+                    stop_colors[4 * j + 0], stop_colors[4 * j + 1],
+                    stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
         j++;
-        dispatch->glUniform4f(stop_color6_uniform_location,
-                              stop_colors[4 * j + 0], stop_colors[4 * j + 1],
-                              stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
+        glUniform4f(stop_color6_uniform_location,
+                    stop_colors[4 * j + 0], stop_colors[4 * j + 1],
+                    stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
         j++;
-        dispatch->glUniform4f(stop_color7_uniform_location,
-                              stop_colors[4 * j + 0], stop_colors[4 * j + 1],
-                              stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
+        glUniform4f(stop_color7_uniform_location,
+                    stop_colors[4 * j + 0], stop_colors[4 * j + 1],
+                    stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
 
         j = 0;
-        dispatch->glUniform1f(stop0_uniform_location, n_stops[j++]);
-        dispatch->glUniform1f(stop1_uniform_location, n_stops[j++]);
-        dispatch->glUniform1f(stop2_uniform_location, n_stops[j++]);
-        dispatch->glUniform1f(stop3_uniform_location, n_stops[j++]);
-        dispatch->glUniform1f(stop4_uniform_location, n_stops[j++]);
-        dispatch->glUniform1f(stop5_uniform_location, n_stops[j++]);
-        dispatch->glUniform1f(stop6_uniform_location, n_stops[j++]);
-        dispatch->glUniform1f(stop7_uniform_location, n_stops[j++]);
-
-        dispatch->glUniform1i(n_stop_uniform_location, count);
+        glUniform1f(stop0_uniform_location, n_stops[j++]);
+        glUniform1f(stop1_uniform_location, n_stops[j++]);
+        glUniform1f(stop2_uniform_location, n_stops[j++]);
+        glUniform1f(stop3_uniform_location, n_stops[j++]);
+        glUniform1f(stop4_uniform_location, n_stops[j++]);
+        glUniform1f(stop5_uniform_location, n_stops[j++]);
+        glUniform1f(stop6_uniform_location, n_stops[j++]);
+        glUniform1f(stop7_uniform_location, n_stops[j++]);
+
+        glUniform1i(n_stop_uniform_location, count);
     }
     else {
-        dispatch->glUniform4fv(stop_colors_uniform_location, count,
-                               stop_colors);
-        dispatch->glUniform1fv(stops_uniform_location, count, n_stops);
-        dispatch->glUniform1i(n_stop_uniform_location, count);
+        glUniform4fv(stop_colors_uniform_location, count, stop_colors);
+        glUniform1fv(stops_uniform_location, count, n_stops);
+        glUniform1i(n_stop_uniform_location, count);
     }
 
     if (src_picture->pSourcePict->linear.p2.y == src_picture->pSourcePict->linear.p1.y) {       // The horizontal case.
-        dispatch->glUniform1i(hor_ver_uniform_location, 1);
+        glUniform1i(hor_ver_uniform_location, 1);
         DEBUGF("p1.y: %f, p2.y: %f, enter the horizontal case\n",
                pt1[1], pt2[1]);
 
         p1_distance = pt1[0];
         pt_distance = (pt2[0] - p1_distance);
-        dispatch->glUniform1f(p1_distance_uniform_location, p1_distance);
-        dispatch->glUniform1f(pt_distance_uniform_location, pt_distance);
+        glUniform1f(p1_distance_uniform_location, p1_distance);
+        glUniform1f(pt_distance_uniform_location, pt_distance);
     }
     else {
         /* The slope need to compute here. In shader, the viewport set will change
@@ -1616,20 +1583,20 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
             (float) (src_picture->pSourcePict->linear.p2.y
                      - src_picture->pSourcePict->linear.p1.y);
         slope = slope * yscale / xscale;
-        dispatch->glUniform1f(pt_slope_uniform_location, slope);
-        dispatch->glUniform1i(hor_ver_uniform_location, 0);
+        glUniform1f(pt_slope_uniform_location, slope);
+        glUniform1i(hor_ver_uniform_location, 0);
 
         cos_val = sqrt(1.0 / (slope * slope + 1.0));
-        dispatch->glUniform1f(cos_val_uniform_location, cos_val);
+        glUniform1f(cos_val_uniform_location, cos_val);
 
         p1_distance = (pt1[1] - pt1[0] * slope) * cos_val;
         pt_distance = (pt2[1] - pt2[0] * slope) * cos_val - p1_distance;
-        dispatch->glUniform1f(p1_distance_uniform_location, p1_distance);
-        dispatch->glUniform1f(pt_distance_uniform_location, pt_distance);
+        glUniform1f(p1_distance_uniform_location, p1_distance);
+        glUniform1f(pt_distance_uniform_location, pt_distance);
     }
 
     /* Now rendering. */
-    dispatch->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
 
     /* Do the clear logic. */
     if (stops_count > LINEAR_SMALL_STOPS) {
@@ -1637,12 +1604,12 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
         free(stop_colors);
     }
 
-    dispatch->glBindBuffer(GL_ARRAY_BUFFER, 0);
-    dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+    glBindBuffer(GL_ARRAY_BUFFER, 0);
+    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
 
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
-    dispatch->glUseProgram(0);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+    glUseProgram(0);
 
     glamor_put_dispatch(glamor_priv);
     return dst_picture;
@@ -1659,12 +1626,12 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
             free(stop_colors);
     }
 
-    dispatch->glBindBuffer(GL_ARRAY_BUFFER, 0);
-    dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+    glBindBuffer(GL_ARRAY_BUFFER, 0);
+    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
 
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
-    dispatch->glUseProgram(0);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+    glUseProgram(0);
     glamor_put_dispatch(glamor_priv);
     return NULL;
 }
diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c
index f7de59c..7f152fc 100644
--- a/glamor/glamor_pixmap.c
+++ b/glamor/glamor_pixmap.c
@@ -66,16 +66,16 @@ void
 glamor_set_destination_pixmap_fbo(glamor_pixmap_fbo *fbo, int x0, int y0,
                                   int width, int height)
 {
-    glamor_gl_dispatch *dispatch = glamor_get_dispatch(fbo->glamor_priv);
+    glamor_get_dispatch(fbo->glamor_priv);
 
-    dispatch->glBindFramebuffer(GL_FRAMEBUFFER, fbo->fb);
+    glBindFramebuffer(GL_FRAMEBUFFER, fbo->fb);
 #ifndef GLAMOR_GLES2
-    dispatch->glMatrixMode(GL_PROJECTION);
-    dispatch->glLoadIdentity();
-    dispatch->glMatrixMode(GL_MODELVIEW);
-    dispatch->glLoadIdentity();
+    glMatrixMode(GL_PROJECTION);
+    glLoadIdentity();
+    glMatrixMode(GL_MODELVIEW);
+    glLoadIdentity();
 #endif
-    dispatch->glViewport(x0, y0, width, height);
+    glViewport(x0, y0, width, height);
 
     glamor_put_dispatch(fbo->glamor_priv);
 }
@@ -121,59 +121,59 @@ glamor_set_planemask(PixmapPtr pixmap, unsigned long planemask)
 }
 
 Bool
-glamor_set_alu(struct glamor_gl_dispatch *dispatch, unsigned char alu)
+glamor_set_alu(unsigned char alu)
 {
 #ifndef GLAMOR_GLES2
     if (alu == GXcopy) {
-        dispatch->glDisable(GL_COLOR_LOGIC_OP);
+        glDisable(GL_COLOR_LOGIC_OP);
         return TRUE;
     }
-    dispatch->glEnable(GL_COLOR_LOGIC_OP);
+    glEnable(GL_COLOR_LOGIC_OP);
     switch (alu) {
     case GXclear:
-        dispatch->glLogicOp(GL_CLEAR);
+        glLogicOp(GL_CLEAR);
         break;
     case GXand:
-        dispatch->glLogicOp(GL_AND);
+        glLogicOp(GL_AND);
         break;
     case GXandReverse:
-        dispatch->glLogicOp(GL_AND_REVERSE);
+        glLogicOp(GL_AND_REVERSE);
         break;
     case GXandInverted:
-        dispatch->glLogicOp(GL_AND_INVERTED);
+        glLogicOp(GL_AND_INVERTED);
         break;
     case GXnoop:
-        dispatch->glLogicOp(GL_NOOP);
+        glLogicOp(GL_NOOP);
         break;
     case GXxor:
-        dispatch->glLogicOp(GL_XOR);
+        glLogicOp(GL_XOR);
         break;
     case GXor:
-        dispatch->glLogicOp(GL_OR);
+        glLogicOp(GL_OR);
         break;
     case GXnor:
-        dispatch->glLogicOp(GL_NOR);
+        glLogicOp(GL_NOR);
         break;
     case GXequiv:
-        dispatch->glLogicOp(GL_EQUIV);
+        glLogicOp(GL_EQUIV);
         break;
     case GXinvert:
-        dispatch->glLogicOp(GL_INVERT);
+        glLogicOp(GL_INVERT);
         break;
     case GXorReverse:
-        dispatch->glLogicOp(GL_OR_REVERSE);
+        glLogicOp(GL_OR_REVERSE);
         break;
     case GXcopyInverted:
-        dispatch->glLogicOp(GL_COPY_INVERTED);
+        glLogicOp(GL_COPY_INVERTED);
         break;
     case GXorInverted:
-        dispatch->glLogicOp(GL_OR_INVERTED);
+        glLogicOp(GL_OR_INVERTED);
         break;
     case GXnand:
-        dispatch->glLogicOp(GL_NAND);
+        glLogicOp(GL_NAND);
         break;
     case GXset:
-        dispatch->glLogicOp(GL_SET);
+        glLogicOp(GL_SET);
         break;
     default:
         glamor_fallback("unsupported alu %x\n", alu);
@@ -397,13 +397,12 @@ __glamor_upload_pixmap_to_texture(PixmapPtr pixmap, unsigned int *tex,
 {
     glamor_screen_private *glamor_priv =
         glamor_get_screen_private(pixmap->drawable.pScreen);
-    glamor_gl_dispatch *dispatch;
     int non_sub = 0;
     unsigned int iformat = 0;
 
-    dispatch = glamor_get_dispatch(glamor_priv);
+    glamor_get_dispatch(glamor_priv);
     if (*tex == 0) {
-        dispatch->glGenTextures(1, tex);
+        glGenTextures(1, tex);
         if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP)
             gl_iformat_for_depth(pixmap->drawable.depth, &iformat);
         else
@@ -412,22 +411,20 @@ __glamor_upload_pixmap_to_texture(PixmapPtr pixmap, unsigned int *tex,
         assert(x == 0 && y == 0);
     }
 
-    dispatch->glBindTexture(GL_TEXTURE_2D, *tex);
-    dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-    dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-    dispatch->glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+    glBindTexture(GL_TEXTURE_2D, *tex);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+    glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
 
     if (bits == NULL)
-        dispatch->glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo);
+        glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo);
     if (non_sub)
-        dispatch->glTexImage2D(GL_TEXTURE_2D,
-                               0, iformat, w, h, 0, format, type, bits);
+        glTexImage2D(GL_TEXTURE_2D, 0, iformat, w, h, 0, format, type, bits);
     else
-        dispatch->glTexSubImage2D(GL_TEXTURE_2D,
-                                  0, x, y, w, h, format, type, bits);
+        glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, format, type, bits);
 
     if (bits == NULL)
-        dispatch->glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
+        glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
     glamor_put_dispatch(glamor_priv);
 }
 
@@ -440,7 +437,6 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, GLenum format,
     glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
     glamor_screen_private *glamor_priv =
         glamor_get_screen_private(pixmap->drawable.pScreen);
-    glamor_gl_dispatch *dispatch;
     static float vertices[8];
 
     static float texcoords[8] = { 0, 1,
@@ -526,40 +522,39 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, GLenum format,
                                  x + w, y + h,
                                  glamor_priv->yInverted, vertices);
     /* Slow path, we need to flip y or wire alpha to 1. */
-    dispatch = glamor_get_dispatch(glamor_priv);
-    dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
-                                    GL_FALSE, 2 * sizeof(float), vertices);
-    dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
-    dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT,
-                                    GL_FALSE, 2 * sizeof(float), ptexcoords);
-    dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+    glamor_get_dispatch(glamor_priv);
+    glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
+                          GL_FALSE, 2 * sizeof(float), vertices);
+    glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+    glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT,
+                          GL_FALSE, 2 * sizeof(float), ptexcoords);
+    glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
 
     glamor_set_destination_pixmap_priv_nc(pixmap_priv);
     __glamor_upload_pixmap_to_texture(pixmap, &tex,
                                       format, type, 0, 0, w, h, bits, pbo);
-    dispatch->glActiveTexture(GL_TEXTURE0);
-    dispatch->glBindTexture(GL_TEXTURE_2D, tex);
+    glActiveTexture(GL_TEXTURE0);
+    glBindTexture(GL_TEXTURE_2D, tex);
 
-    dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-    dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 #ifndef GLAMOR_GLES2
-    dispatch->glEnable(GL_TEXTURE_2D);
+    glEnable(GL_TEXTURE_2D);
 #endif
-    dispatch->glUseProgram(glamor_priv->finish_access_prog[no_alpha]);
-    dispatch->glUniform1i(glamor_priv->finish_access_revert[no_alpha], revert);
-    dispatch->glUniform1i(glamor_priv->finish_access_swap_rb[no_alpha],
-                          swap_rb);
+    glUseProgram(glamor_priv->finish_access_prog[no_alpha]);
+    glUniform1i(glamor_priv->finish_access_revert[no_alpha], revert);
+    glUniform1i(glamor_priv->finish_access_swap_rb[no_alpha], swap_rb);
 
-    dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+    glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
 
 #ifndef GLAMOR_GLES2
-    dispatch->glDisable(GL_TEXTURE_2D);
+    glDisable(GL_TEXTURE_2D);
 #endif
-    dispatch->glUseProgram(0);
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
-    dispatch->glDeleteTextures(1, &tex);
-    dispatch->glBindFramebuffer(GL_FRAMEBUFFER, 0);
+    glUseProgram(0);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+    glDeleteTextures(1, &tex);
+    glBindFramebuffer(GL_FRAMEBUFFER, 0);
 
     glamor_put_dispatch(glamor_priv);
 
@@ -831,7 +826,6 @@ glamor_es2_pixmap_read_prepare(PixmapPtr source, int x, int y, int w, int h,
     glamor_screen_private *glamor_priv;
     ScreenPtr screen;
     glamor_pixmap_fbo *temp_fbo;
-    glamor_gl_dispatch *dispatch;
     float temp_xscale, temp_yscale, source_xscale, source_yscale;
     static float vertices[8];
     static float texcoords[8];
@@ -844,7 +838,7 @@ glamor_es2_pixmap_read_prepare(PixmapPtr source, int x, int y, int w, int h,
     if (temp_fbo == NULL)
         return NULL;
 
-    dispatch = glamor_get_dispatch(glamor_priv);
+    glamor_get_dispatch(glamor_priv);
     temp_xscale = 1.0 / w;
     temp_yscale = 1.0 / h;
 
@@ -852,9 +846,9 @@ glamor_es2_pixmap_read_prepare(PixmapPtr source, int x, int y, int w, int h,
                                  temp_xscale, temp_yscale, 0, 0, w, h,
                                  glamor_priv->yInverted, vertices);
 
-    dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
-                                    GL_FALSE, 2 * sizeof(float), vertices);
-    dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+    glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT, GL_FALSE,
+                          2 * sizeof(float), vertices);
+    glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
 
     pixmap_priv_get_scale(source_priv, &source_xscale, &source_yscale);
     glamor_set_normalize_tcoords(source_priv, source_xscale,
@@ -863,26 +857,25 @@ glamor_es2_pixmap_read_prepare(PixmapPtr source, int x, int y, int w, int h,
                                  x + w, y + h,
                                  glamor_priv->yInverted, texcoords);
 
-    dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT,
-                                    GL_FALSE, 2 * sizeof(float), texcoords);
-    dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+    glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT, GL_FALSE,
+                          2 * sizeof(float), texcoords);
+    glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
 
-    dispatch->glActiveTexture(GL_TEXTURE0);
-    dispatch->glBindTexture(GL_TEXTURE_2D, source_priv->base.fbo->tex);
-    dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-    dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+    glActiveTexture(GL_TEXTURE0);
+    glBindTexture(GL_TEXTURE_2D, source_priv->base.fbo->tex);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 
     glamor_set_destination_pixmap_fbo(temp_fbo, 0, 0, w, h);
-    dispatch->glUseProgram(glamor_priv->finish_access_prog[no_alpha]);
-    dispatch->glUniform1i(glamor_priv->finish_access_revert[no_alpha], revert);
-    dispatch->glUniform1i(glamor_priv->finish_access_swap_rb[no_alpha],
-                          swap_rb);
+    glUseProgram(glamor_priv->finish_access_prog[no_alpha]);
+    glUniform1i(glamor_priv->finish_access_revert[no_alpha], revert);
+    glUniform1i(glamor_priv->finish_access_swap_rb[no_alpha], swap_rb);
 
-    dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+    glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
 
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
-    dispatch->glUseProgram(0);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+    glUseProgram(0);
     glamor_put_dispatch(glamor_priv);
     return temp_fbo;
 }
@@ -905,7 +898,6 @@ _glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, GLenum format,
     void *data, *read;
     glamor_screen_private *glamor_priv =
         glamor_get_screen_private(pixmap->drawable.pScreen);
-    glamor_gl_dispatch *dispatch;
     glamor_pixmap_fbo *temp_fbo = NULL;
     int need_post_conversion = 0;
     int need_free_data = 0;
@@ -964,56 +956,52 @@ _glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, GLenum format,
         fbo_y_off = 0;
     }
 
-    dispatch = glamor_get_dispatch(glamor_priv);
-    dispatch->glPixelStorei(GL_PACK_ALIGNMENT, 4);
+    glamor_get_dispatch(glamor_priv);
+    glPixelStorei(GL_PACK_ALIGNMENT, 4);
 
     if (glamor_priv->has_pack_invert || glamor_priv->yInverted) {
 
         if (!glamor_priv->yInverted) {
             assert(glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP);
-            dispatch->glPixelStorei(GL_PACK_INVERT_MESA, 1);
+            glPixelStorei(GL_PACK_INVERT_MESA, 1);
         }
 
         if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP && data == NULL) {
             assert(pbo > 0);
-            dispatch->glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo);
-            dispatch->glBufferData(GL_PIXEL_PACK_BUFFER,
-                                   stride * h, NULL, gl_usage);
+            glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo);
+            glBufferData(GL_PIXEL_PACK_BUFFER, stride * h, NULL, gl_usage);
         }
 
-        dispatch->glReadPixels(x + fbo_x_off, y + fbo_y_off, w, h, format, type,
-                               data);
+        glReadPixels(x + fbo_x_off, y + fbo_y_off, w, h, format, type, data);
 
         if (!glamor_priv->yInverted) {
             assert(glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP);
-            dispatch->glPixelStorei(GL_PACK_INVERT_MESA, 0);
+            glPixelStorei(GL_PACK_INVERT_MESA, 0);
         }
         if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP && bits == NULL) {
-            bits = dispatch->glMapBuffer(GL_PIXEL_PACK_BUFFER, gl_access);
-            dispatch->glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
+            bits = glMapBuffer(GL_PIXEL_PACK_BUFFER, gl_access);
+            glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
         }
     }
     else {
         unsigned int temp_pbo;
         int yy;
 
-        dispatch = glamor_get_dispatch(glamor_priv);
-        dispatch->glGenBuffers(1, &temp_pbo);
-        dispatch->glBindBuffer(GL_PIXEL_PACK_BUFFER, temp_pbo);
-        dispatch->glBufferData(GL_PIXEL_PACK_BUFFER,
-                               stride * h, NULL, GL_STREAM_READ);
-        dispatch->glReadPixels(x + fbo_x_off, y + fbo_y_off, w, h,
-                               format, type, 0);
-        read = dispatch->glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);
+        glamor_get_dispatch(glamor_priv);
+        glGenBuffers(1, &temp_pbo);
+        glBindBuffer(GL_PIXEL_PACK_BUFFER, temp_pbo);
+        glBufferData(GL_PIXEL_PACK_BUFFER, stride * h, NULL, GL_STREAM_READ);
+        glReadPixels(x + fbo_x_off, y + fbo_y_off, w, h, format, type, 0);
+        read = glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);
         for (yy = 0; yy < pixmap->drawable.height; yy++)
             memcpy((char *) data + yy * stride,
                    (char *) read + (h - yy - 1) * stride, stride);
-        dispatch->glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
-        dispatch->glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
-        dispatch->glDeleteBuffers(1, &temp_pbo);
+        glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
+        glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
+        glDeleteBuffers(1, &temp_pbo);
     }
 
-    dispatch->glBindFramebuffer(GL_FRAMEBUFFER, 0);
+    glBindFramebuffer(GL_FRAMEBUFFER, 0);
     glamor_put_dispatch(glamor_priv);
 
     if (need_post_conversion) {
@@ -1168,7 +1156,6 @@ glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access)
     void *data = NULL, *dst;
     glamor_screen_private *glamor_priv =
         glamor_get_screen_private(pixmap->drawable.pScreen);
-    glamor_gl_dispatch *dispatch;
     int pbo = 0;
 
     if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
@@ -1189,9 +1176,9 @@ glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access)
         data = malloc(stride * pixmap->drawable.height);
     }
     else {
-        dispatch = glamor_get_dispatch(glamor_priv);
+        glamor_get_dispatch(glamor_priv);
         if (pixmap_priv->base.fbo->pbo == 0)
-            dispatch->glGenBuffers(1, &pixmap_priv->base.fbo->pbo);
+            glGenBuffers(1, &pixmap_priv->base.fbo->pbo);
         glamor_put_dispatch(glamor_priv);
         pbo = pixmap_priv->base.fbo->pbo;
     }
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index dc38730..8477091 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -35,15 +35,11 @@
 #endif
 #include "glamor.h"
 
-#ifdef GLAMOR_GLES2
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
+#include <epoxy/gl.h>
 
+#ifdef GLAMOR_GLES2
 #define GLAMOR_DEFAULT_PRECISION   "precision mediump float;\n"
-#include "glamor_glext.h"
 #else
-#include <GL/gl.h>
-#include <GL/glext.h>
 #define GLAMOR_DEFAULT_PRECISION
 #endif
 
@@ -178,8 +174,6 @@ typedef struct {
     uint16_t evict;
 } glamor_glyph_cache_t;
 
-#include "glamor_gl_dispatch.h"
-
 struct glamor_saved_procs {
     CloseScreenProcPtr close_screen;
     CreateGCProcPtr create_gc;
@@ -220,7 +214,6 @@ struct glamor_saved_procs {
 #define RENDER_IDEL_MAX 32
 
 typedef struct glamor_screen_private {
-    struct glamor_gl_dispatch _dispatch;
     int yInverted;
     unsigned int tick;
     enum glamor_gl_flavor gl_flavor;
@@ -583,9 +576,8 @@ Bool glamor_stipple(PixmapPtr pixmap, PixmapPtr stipple,
                     unsigned char alu, unsigned long planemask,
                     unsigned long fg_pixel, unsigned long bg_pixel,
                     int stipple_x, int stipple_y);
-GLint glamor_compile_glsl_prog(glamor_gl_dispatch *dispatch, GLenum type,
-                               const char *source);
-void glamor_link_glsl_prog(glamor_gl_dispatch *dispatch, GLint prog);
+GLint glamor_compile_glsl_prog(GLenum type, const char *source);
+void glamor_link_glsl_prog(GLint prog);
 void glamor_get_color_4f_from_pixel(PixmapPtr pixmap,
                                     unsigned long fg_pixel, GLfloat *color);
 
@@ -604,7 +596,7 @@ glamor_pixmap_fbo *glamor_es2_pixmap_read_prepare(PixmapPtr source, int x,
                                                   int no_alpha, int revert,
                                                   int swap_rb);
 
-Bool glamor_set_alu(struct glamor_gl_dispatch *dispatch, unsigned char alu);
+Bool glamor_set_alu(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);
diff --git a/glamor/glamor_putimage.c b/glamor/glamor_putimage.c
index 6b25bec..60ccd67 100644
--- a/glamor/glamor_putimage.c
+++ b/glamor/glamor_putimage.c
@@ -67,27 +67,26 @@ glamor_init_putimage_shaders(ScreenPtr screen)
     if (!GLEW_ARB_fragment_shader)
         return;
 
-    prog = dispatch->glCreateProgram();
+    prog = glCreateProgram();
     vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, xybitmap_vs);
     fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, xybitmap_fs);
-    dispatch->glAttachShader(prog, vs_prog);
-    dispatch->glAttachShader(prog, fs_prog);
+    glAttachShader(prog, vs_prog);
+    glAttachShader(prog, fs_prog);
     glamor_link_glsl_prog(prog);
 
-    dispatch->glUseProgram(prog);
-    sampler_uniform_location =
-        dispatch->glGetUniformLocation(prog, "bitmap_sampler");
-    dispatch->glUniform1i(sampler_uniform_location, 0);
+    glUseProgram(prog);
+    sampler_uniform_location = glGetUniformLocation(prog, "bitmap_sampler");
+    glUniform1i(sampler_uniform_location, 0);
 
     glamor_priv->put_image_xybitmap_fg_uniform_location =
-        dispatch->glGetUniformLocation(prog, "fg");
+        glGetUniformLocation(prog, "fg");
     glamor_priv->put_image_xybitmap_bg_uniform_location =
-        dispatch->glGetUniformLocation(prog, "bg");
+        glGetUniformLocation(prog, "bg");
     glamor_get_transform_uniform_locations(prog,
                                            &glamor_priv->
                                            put_image_xybitmap_transform);
     glamor_priv->put_image_xybitmap_prog = prog;
-    dispatch->glUseProgram(0);
+    glUseProgram(0);
 #endif
 }
 
@@ -162,40 +161,38 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
     if (!glamor_set_planemask(pixmap, gc->planemask))
         goto fail;
 
-    dispatch->glUseProgram(glamor_priv->put_image_xybitmap_prog);
+    glUseProgram(glamor_priv->put_image_xybitmap_prog);
 
     glamor_get_color_4f_from_pixel(pixmap, gc->fgPixel, fg);
-    dispatch->glUniform4fv
-        (glamor_priv->put_image_xybitmap_fg_uniform_location, 1, fg);
+    glUniform4fv(glamor_priv->put_image_xybitmap_fg_uniform_location, 1, fg);
     glamor_get_color_4f_from_pixel(pixmap, gc->bgPixel, bg);
-    dispatch->glUniform4fv
-        (glamor_priv->put_image_xybitmap_bg_uniform_location, 1, bg);
-
-    dispatch->glGenTextures(1, &tex);
-    dispatch->glActiveTexture(GL_TEXTURE0);
-    dispatch->glEnable(GL_TEXTURE_2D);
-    dispatch->glBindTexture(GL_TEXTURE_2D, tex);
-    dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-    dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-    dispatch->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-    dispatch->glPixelStorei(GL_UNPACK_ROW_LENGTH, stride * 8);
-    dispatch->glPixelStorei(GL_UNPACK_SKIP_PIXELS, left_pad);
-    dispatch->glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA,
-                           w, h, 0, GL_COLOR_INDEX, GL_BITMAP, bits);
-    dispatch->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
-    dispatch->glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
+    glUniform4fv(glamor_priv->put_image_xybitmap_bg_uniform_location, 1, bg);
+
+    glGenTextures(1, &tex);
+    glActiveTexture(GL_TEXTURE0);
+    glEnable(GL_TEXTURE_2D);
+    glBindTexture(GL_TEXTURE_2D, tex);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+    glPixelStorei(GL_UNPACK_ROW_LENGTH, stride * 8);
+    glPixelStorei(GL_UNPACK_SKIP_PIXELS, left_pad);
+    glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA,
+                 w, h, 0, GL_COLOR_INDEX, GL_BITMAP, bits);
+    glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+    glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
 
     /* Now that we've set up our bitmap texture and the shader, shove
      * the destination rectangle through the cliprects and run the
      * shader on the resulting fragments.
      */
-    dispatch->glVertexPointer(2, GL_FLOAT, 0, dest_coords);
-    dispatch->glEnableClientState(GL_VERTEX_ARRAY);
-    dispatch->glClientActiveTexture(GL_TEXTURE0);
-    dispatch->glTexCoordPointer(2, GL_FLOAT, 0, bitmap_coords);
-    dispatch->glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+    glVertexPointer(2, GL_FLOAT, 0, dest_coords);
+    glEnableClientState(GL_VERTEX_ARRAY);
+    glClientActiveTexture(GL_TEXTURE0);
+    glTexCoordPointer(2, GL_FLOAT, 0, bitmap_coords);
+    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
 
-    dispatch->glEnable(GL_SCISSOR_TEST);
+    glEnable(GL_SCISSOR_TEST);
     clip = fbGetCompositeClip(gc);
     for (nbox = REGION_NUM_RECTS(clip), box = REGION_RECTS(clip); nbox--; box++) {
         int x1 = x;
@@ -214,19 +211,18 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
         if (x1 >= x2 || y1 >= y2)
             continue;
 
-        dispatch->glScissor(box->x1,
-                            y_flip(pixmap, box->y1),
-                            box->x2 - box->x1, box->y2 - box->y1);
-        dispatch->glDrawArrays(GL_QUADS, 0, 4);
+        glScissor(box->x1, y_flip(pixmap, box->y1),
+                  box->x2 - box->x1, box->y2 - box->y1);
+        glDrawArrays(GL_QUADS, 0, 4);
     }
 
-    dispatch->glDisable(GL_SCISSOR_TEST);
+    glDisable(GL_SCISSOR_TEST);
     glamor_set_alu(GXcopy);
     glamor_set_planemask(pixmap, ~0);
-    dispatch->glDeleteTextures(1, &tex);
-    dispatch->glDisable(GL_TEXTURE_2D);
-    dispatch->glDisableClientState(GL_VERTEX_ARRAY);
-    dispatch->glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+    glDeleteTextures(1, &tex);
+    glDisable(GL_TEXTURE_2D);
+    glDisableClientState(GL_VERTEX_ARRAY);
+    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
     return;
     glamor_set_alu(GXcopy);
     glamor_set_planemask(pixmap, ~0);
diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index 4a3a97c..760af83 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -62,8 +62,7 @@ static struct blendinfo composite_op_info[] = {
 
 #define RepeatFix			10
 static GLuint
-glamor_create_composite_fs(glamor_gl_dispatch *dispatch,
-                           struct shader_key *key)
+glamor_create_composite_fs(struct shader_key *key)
 {
     const char *repeat_define =
         "#define RepeatNone               	      0\n"
@@ -266,15 +265,14 @@ glamor_create_composite_fs(glamor_gl_dispatch *dispatch,
     XNFasprintf(&source, "%s%s%s%s%s%s", repeat_define, relocate_texture,
                 rel_sampler, source_fetch, mask_fetch, in);
 
-    prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER, source);
+    prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, source);
     free(source);
 
     return prog;
 }
 
 static GLuint
-glamor_create_composite_vs(glamor_gl_dispatch *dispatch,
-                           struct shader_key *key)
+glamor_create_composite_vs(struct shader_key *key)
 {
     const char *main_opening =
         "attribute vec4 v_position;\n"
@@ -304,7 +302,7 @@ glamor_create_composite_vs(glamor_gl_dispatch *dispatch,
                 main_opening,
                 source_coords_setup, mask_coords_setup, main_closing);
 
-    prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, source);
+    prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, source);
     free(source);
 
     return prog;
@@ -317,55 +315,52 @@ glamor_create_composite_shader(ScreenPtr screen, struct shader_key *key,
     GLuint vs, fs, prog;
     GLint source_sampler_uniform_location, mask_sampler_uniform_location;
     glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
-    glamor_gl_dispatch *dispatch;
 
-    dispatch = glamor_get_dispatch(glamor_priv);
-    vs = glamor_create_composite_vs(dispatch, key);
+    glamor_get_dispatch(glamor_priv);
+    vs = glamor_create_composite_vs(key);
     if (vs == 0)
         goto out;
-    fs = glamor_create_composite_fs(dispatch, key);
+    fs = glamor_create_composite_fs(key);
     if (fs == 0)
         goto out;
 
-    prog = dispatch->glCreateProgram();
-    dispatch->glAttachShader(prog, vs);
-    dispatch->glAttachShader(prog, fs);
+    prog = glCreateProgram();
+    glAttachShader(prog, vs);
+    glAttachShader(prog, fs);
 
-    dispatch->glBindAttribLocation(prog, GLAMOR_VERTEX_POS, "v_position");
-    dispatch->glBindAttribLocation(prog, GLAMOR_VERTEX_SOURCE, "v_texcoord0");
-    dispatch->glBindAttribLocation(prog, GLAMOR_VERTEX_MASK, "v_texcoord1");
+    glBindAttribLocation(prog, GLAMOR_VERTEX_POS, "v_position");
+    glBindAttribLocation(prog, GLAMOR_VERTEX_SOURCE, "v_texcoord0");
+    glBindAttribLocation(prog, GLAMOR_VERTEX_MASK, "v_texcoord1");
 
-    glamor_link_glsl_prog(dispatch, prog);
+    glamor_link_glsl_prog(prog);
 
     shader->prog = prog;
 
-    dispatch->glUseProgram(prog);
+    glUseProgram(prog);
 
     if (key->source == SHADER_SOURCE_SOLID) {
-        shader->source_uniform_location =
-            dispatch->glGetUniformLocation(prog, "source");
+        shader->source_uniform_location = glGetUniformLocation(prog, "source");
     }
     else {
         source_sampler_uniform_location =
-            dispatch->glGetUniformLocation(prog, "source_sampler");
-        dispatch->glUniform1i(source_sampler_uniform_location, 0);
-        shader->source_wh = dispatch->glGetUniformLocation(prog, "source_wh");
+            glGetUniformLocation(prog, "source_sampler");
+        glUniform1i(source_sampler_uniform_location, 0);
+        shader->source_wh = glGetUniformLocation(prog, "source_wh");
         shader->source_repeat_mode =
-            dispatch->glGetUniformLocation(prog, "source_repeat_mode");
+            glGetUniformLocation(prog, "source_repeat_mode");
     }
 
     if (key->mask != SHADER_MASK_NONE) {
         if (key->mask == SHADER_MASK_SOLID) {
-            shader->mask_uniform_location =
-                dispatch->glGetUniformLocation(prog, "mask");
+            shader->mask_uniform_location = glGetUniformLocation(prog, "mask");
         }
         else {
             mask_sampler_uniform_location =
-                dispatch->glGetUniformLocation(prog, "mask_sampler");
-            dispatch->glUniform1i(mask_sampler_uniform_location, 1);
-            shader->mask_wh = dispatch->glGetUniformLocation(prog, "mask_wh");
+                glGetUniformLocation(prog, "mask_sampler");
+            glUniform1i(mask_sampler_uniform_location, 1);
+            shader->mask_wh = glGetUniformLocation(prog, "mask_wh");
             shader->mask_repeat_mode =
-                dispatch->glGetUniformLocation(prog, "mask_repeat_mode");
+                glGetUniformLocation(prog, "mask_repeat_mode");
         }
     }
 
@@ -407,23 +402,21 @@ void
 glamor_init_composite_shaders(ScreenPtr screen)
 {
     glamor_screen_private *glamor_priv;
-    glamor_gl_dispatch *dispatch;
     unsigned short *eb;
     float *vb = NULL;
     int eb_size;
 
     glamor_priv = glamor_get_screen_private(screen);
-    dispatch = glamor_get_dispatch(glamor_priv);
-    dispatch->glGenBuffers(1, &glamor_priv->vbo);
-    dispatch->glGenBuffers(1, &glamor_priv->ebo);
-    dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glamor_priv->ebo);
+    glamor_get_dispatch(glamor_priv);
+    glGenBuffers(1, &glamor_priv->vbo);
+    glGenBuffers(1, &glamor_priv->ebo);
+    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glamor_priv->ebo);
 
     eb_size = GLAMOR_COMPOSITE_VBO_VERT_CNT * sizeof(short) * 2;
 
     if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
-        dispatch->glBufferData(GL_ELEMENT_ARRAY_BUFFER,
-                               eb_size, NULL, GL_STATIC_DRAW);
-        eb = dispatch->glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY);
+        glBufferData(GL_ELEMENT_ARRAY_BUFFER, eb_size, NULL, GL_STATIC_DRAW);
+        eb = glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY);
     }
     else {
         vb = malloc(GLAMOR_COMPOSITE_VBO_VERT_CNT * sizeof(float) * 2);
@@ -438,19 +431,18 @@ glamor_init_composite_shaders(ScreenPtr screen)
     glamor_init_eb(eb, GLAMOR_COMPOSITE_VBO_VERT_CNT);
 
     if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
-        dispatch->glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER);
-        dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+        glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER);
+        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
     }
     else {
-        dispatch->glBufferData(GL_ELEMENT_ARRAY_BUFFER,
-                               eb_size, eb, GL_STATIC_DRAW);
-        dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+        glBufferData(GL_ELEMENT_ARRAY_BUFFER, eb_size, eb, GL_STATIC_DRAW);
+        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
 
-        dispatch->glBindBuffer(GL_ARRAY_BUFFER, glamor_priv->vbo);
-        dispatch->glBufferData(GL_ARRAY_BUFFER,
-                               GLAMOR_COMPOSITE_VBO_VERT_CNT * sizeof(float) *
-                               2, NULL, GL_DYNAMIC_DRAW);
-        dispatch->glBindBuffer(GL_ARRAY_BUFFER, 0);
+        glBindBuffer(GL_ARRAY_BUFFER, glamor_priv->vbo);
+        glBufferData(GL_ARRAY_BUFFER,
+                     GLAMOR_COMPOSITE_VBO_VERT_CNT * sizeof(float) *
+                     2, NULL, GL_DYNAMIC_DRAW);
+        glBindBuffer(GL_ARRAY_BUFFER, 0);
 
         free(eb);
         glamor_priv->vb = (char *) vb;
@@ -463,21 +455,20 @@ void
 glamor_fini_composite_shaders(ScreenPtr screen)
 {
     glamor_screen_private *glamor_priv;
-    glamor_gl_dispatch *dispatch;
     glamor_composite_shader *shader;
     int i, j, k;
 
     glamor_priv = glamor_get_screen_private(screen);
-    dispatch = glamor_get_dispatch(glamor_priv);
-    dispatch->glDeleteBuffers(1, &glamor_priv->vbo);
-    dispatch->glDeleteBuffers(1, &glamor_priv->ebo);
+    glamor_get_dispatch(glamor_priv);
+    glDeleteBuffers(1, &glamor_priv->vbo);
+    glDeleteBuffers(1, &glamor_priv->ebo);
 
     for (i = 0; i < SHADER_SOURCE_COUNT; i++)
         for (j = 0; j < SHADER_MASK_COUNT; j++)
             for (k = 0; k < SHADER_IN_COUNT; k++) {
                 shader = &glamor_priv->composite_shader[i][j][k];
                 if (shader->prog)
-                    dispatch->glDeleteProgram(shader->prog);
+                    glDeleteProgram(shader->prog);
             }
     if (glamor_priv->gl_flavor != GLAMOR_GL_DESKTOP && glamor_priv->vb)
         free(glamor_priv->vb);
@@ -535,44 +526,35 @@ glamor_set_composite_texture(glamor_screen_private *glamor_priv, int unit,
                              glamor_pixmap_private *pixmap_priv,
                              GLuint wh_location, GLuint repeat_location)
 {
-    glamor_gl_dispatch *dispatch;
     float wh[4];
     int repeat_type;
 
-    dispatch = glamor_get_dispatch(glamor_priv);
-    dispatch->glActiveTexture(GL_TEXTURE0 + unit);
-    dispatch->glBindTexture(GL_TEXTURE_2D, pixmap_priv->base.fbo->tex);
+    glamor_get_dispatch(glamor_priv);
+    glActiveTexture(GL_TEXTURE0 + unit);
+    glBindTexture(GL_TEXTURE_2D, pixmap_priv->base.fbo->tex);
     repeat_type = picture->repeatType;
     switch (picture->repeatType) {
     case RepeatNone:
 #ifndef GLAMOR_GLES2
         /* XXX  GLES2 doesn't support GL_CLAMP_TO_BORDER. */
-        dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
-                                  GL_CLAMP_TO_BORDER);
-        dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
-                                  GL_CLAMP_TO_BORDER);
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
 #else
-        dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
-                                  GL_CLAMP_TO_EDGE);
-        dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
-                                  GL_CLAMP_TO_EDGE);
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
 #endif
         break;
     case RepeatNormal:
-        dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
-        dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
         break;
     case RepeatPad:
-        dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
-                                  GL_CLAMP_TO_EDGE);
-        dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
-                                  GL_CLAMP_TO_EDGE);
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
         break;
     case RepeatReflect:
-        dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
-                                  GL_MIRRORED_REPEAT);
-        dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
-                                  GL_MIRRORED_REPEAT);
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
         break;
     }
 
@@ -580,22 +562,18 @@ glamor_set_composite_texture(glamor_screen_private *glamor_priv, int unit,
     default:
     case PictFilterFast:
     case PictFilterNearest:
-        dispatch->glTexParameteri(GL_TEXTURE_2D,
-                                  GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-        dispatch->glTexParameteri(GL_TEXTURE_2D,
-                                  GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
         break;
     case PictFilterGood:
     case PictFilterBest:
     case PictFilterBilinear:
-        dispatch->glTexParameteri(GL_TEXTURE_2D,
-                                  GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-        dispatch->glTexParameteri(GL_TEXTURE_2D,
-                                  GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
         break;
     }
 #ifndef GLAMOR_GLES2
-    dispatch->glEnable(GL_TEXTURE_2D);
+    glEnable(GL_TEXTURE_2D);
 #endif
 
     /*
@@ -615,19 +593,18 @@ glamor_set_composite_texture(glamor_screen_private *glamor_priv, int unit,
         if ((wh[0] != 1.0 || wh[1] != 1.0)
             || (glamor_priv->gl_flavor == GLAMOR_GL_ES2
                 && repeat_type == RepeatFix))
-            dispatch->glUniform4fv(wh_location, 1, wh);
+            glUniform4fv(wh_location, 1, wh);
         else
             repeat_type -= RepeatFix;
     }
-    dispatch->glUniform1i(repeat_location, repeat_type);
+    glUniform1i(repeat_location, repeat_type);
     glamor_put_dispatch(glamor_priv);
 }
 
 static void
-glamor_set_composite_solid(glamor_gl_dispatch *dispatch, float *color,
-                           GLint uniform_location)
+glamor_set_composite_solid(float *color, GLint uniform_location)
 {
-    dispatch->glUniform4fv(uniform_location, 1, color);
+    glUniform4fv(uniform_location, 1, color);
 }
 
 static int
@@ -729,7 +706,6 @@ void
 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;
 
     glamor_priv->render_nr_verts = 0;
@@ -741,63 +717,52 @@ glamor_setup_composite_vbo(ScreenPtr screen, int n_verts)
 
     vert_size = n_verts * glamor_priv->vb_stride;
 
-    dispatch = glamor_get_dispatch(glamor_priv);
-    dispatch->glBindBuffer(GL_ARRAY_BUFFER, glamor_priv->vbo);
+    glamor_get_dispatch(glamor_priv);
+    glBindBuffer(GL_ARRAY_BUFFER, glamor_priv->vbo);
     if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
         if (glamor_priv->vbo_size < (glamor_priv->vbo_offset + vert_size)) {
             glamor_priv->vbo_size = GLAMOR_COMPOSITE_VBO_VERT_CNT *
                 glamor_priv->vb_stride;
             glamor_priv->vbo_offset = 0;
-            dispatch->glBufferData(GL_ARRAY_BUFFER,
-                                   glamor_priv->vbo_size, NULL, GL_STREAM_DRAW);
+            glBufferData(GL_ARRAY_BUFFER,
+                         glamor_priv->vbo_size, NULL, GL_STREAM_DRAW);
         }
 
-        glamor_priv->vb = dispatch->glMapBufferRange(GL_ARRAY_BUFFER,
-                                                     glamor_priv->vbo_offset,
-                                                     vert_size,
-                                                     GL_MAP_WRITE_BIT |
-                                                     GL_MAP_UNSYNCHRONIZED_BIT);
+        glamor_priv->vb = glMapBufferRange(GL_ARRAY_BUFFER,
+                                           glamor_priv->vbo_offset,
+                                           vert_size,
+                                           GL_MAP_WRITE_BIT |
+                                           GL_MAP_UNSYNCHRONIZED_BIT);
         assert(glamor_priv->vb != NULL);
         glamor_priv->vb -= glamor_priv->vbo_offset;
     }
     else
         glamor_priv->vbo_offset = 0;
 
-    dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glamor_priv->ebo);
+    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glamor_priv->ebo);
 
-    dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
-                                    GL_FALSE, glamor_priv->vb_stride,
-                                    (void *) ((long)
-                                              glamor_priv->vbo_offset));
-    dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+    glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT, GL_FALSE,
+                          glamor_priv->vb_stride,
+                          (void *) ((long)
+                                    glamor_priv->vbo_offset));
+    glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
 
     if (glamor_priv->has_source_coords) {
-        dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
-                                        GL_FLOAT, GL_FALSE,
-                                        glamor_priv->vb_stride, (void *) ((long)
-                                                                          glamor_priv->
-                                                                          vbo_offset
-                                                                          +
-                                                                          2 *
-                                                                          sizeof
-                                                                          (float)));
-        dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+        glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
+                              GL_FLOAT, GL_FALSE,
+                              glamor_priv->vb_stride,
+                              (void *) ((long) glamor_priv->vbo_offset +
+                                        2 * sizeof(float)));
+        glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
     }
 
     if (glamor_priv->has_mask_coords) {
-        dispatch->glVertexAttribPointer(GLAMOR_VERTEX_MASK, 2,
-                                        GL_FLOAT, GL_FALSE,
-                                        glamor_priv->vb_stride, (void *) ((long)
-                                                                          glamor_priv->
-                                                                          vbo_offset
-                                                                          +
-                                                                          (glamor_priv->
-                                                                           has_source_coords
-                                                                           ? 4 :
-                                                                           2) *
-                                                                          sizeof
-                                                                          (float)));
-        dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_MASK);
+        glVertexAttribPointer(GLAMOR_VERTEX_MASK, 2, GL_FLOAT, GL_FALSE,
+                              glamor_priv->vb_stride,
+                              (void *) ((long) glamor_priv->vbo_offset +
+                                        (glamor_priv->has_source_coords ?
+                                         4 : 2) * sizeof(float)));
+        glEnableVertexAttribArray(GLAMOR_VERTEX_MASK);
     }
     glamor_put_dispatch(glamor_priv);
 }
@@ -831,30 +796,27 @@ static void
 glamor_flush_composite_rects(ScreenPtr screen)
 {
     glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
-    glamor_gl_dispatch *dispatch;
 
-    dispatch = glamor_get_dispatch(glamor_priv);
+    glamor_get_dispatch(glamor_priv);
     if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP)
-        dispatch->glUnmapBuffer(GL_ARRAY_BUFFER);
+        glUnmapBuffer(GL_ARRAY_BUFFER);
     else {
 
-        dispatch->glBindBuffer(GL_ARRAY_BUFFER, glamor_priv->vbo);
-        dispatch->glBufferData(GL_ARRAY_BUFFER,
-                               glamor_priv->vbo_offset,
-                               glamor_priv->vb, GL_DYNAMIC_DRAW);
+        glBindBuffer(GL_ARRAY_BUFFER, glamor_priv->vbo);
+        glBufferData(GL_ARRAY_BUFFER, glamor_priv->vbo_offset,
+                     glamor_priv->vb, GL_DYNAMIC_DRAW);
     }
 
     if (!glamor_priv->render_nr_verts)
         return;
 
 #ifndef GLAMOR_GLES2
-    dispatch->glDrawRangeElements(GL_TRIANGLES, 0, glamor_priv->render_nr_verts,
-                                  (glamor_priv->render_nr_verts * 3) / 2,
-                                  GL_UNSIGNED_SHORT, NULL);
+    glDrawRangeElements(GL_TRIANGLES, 0, glamor_priv->render_nr_verts,
+                        (glamor_priv->render_nr_verts * 3) / 2,
+                        GL_UNSIGNED_SHORT, NULL);
 #else
-    dispatch->glDrawElements(GL_TRIANGLES,
-                             (glamor_priv->render_nr_verts * 3) / 2,
-                             GL_UNSIGNED_SHORT, NULL);
+    glDrawElements(GL_TRIANGLES, (glamor_priv->render_nr_verts * 3) / 2,
+                   GL_UNSIGNED_SHORT, NULL);
 #endif
     glamor_put_dispatch(glamor_priv);
 }
@@ -1228,17 +1190,15 @@ glamor_composite_set_shader_blend(glamor_pixmap_private *dest_priv,
                                   glamor_composite_shader *shader,
                                   struct blendinfo *op_info)
 {
-    glamor_gl_dispatch *dispatch;
     glamor_screen_private *glamor_priv;
 
     glamor_priv = dest_priv->base.glamor_priv;
 
-    dispatch = glamor_get_dispatch(glamor_priv);
-    dispatch->glUseProgram(shader->prog);
+    glamor_get_dispatch(glamor_priv);
+    glUseProgram(shader->prog);
 
     if (key->source == SHADER_SOURCE_SOLID) {
-        glamor_set_composite_solid(dispatch,
-                                   shader->source_solid_color,
+        glamor_set_composite_solid(shader->source_solid_color,
                                    shader->source_uniform_location);
     }
     else {
@@ -1250,8 +1210,7 @@ glamor_composite_set_shader_blend(glamor_pixmap_private *dest_priv,
 
     if (key->mask != SHADER_MASK_NONE) {
         if (key->mask == SHADER_MASK_SOLID) {
-            glamor_set_composite_solid(dispatch,
-                                       shader->mask_solid_color,
+            glamor_set_composite_solid(shader->mask_solid_color,
                                        shader->mask_uniform_location);
         }
         else {
@@ -1263,11 +1222,11 @@ glamor_composite_set_shader_blend(glamor_pixmap_private *dest_priv,
     }
 
     if (op_info->source_blend == GL_ONE && op_info->dest_blend == GL_ZERO) {
-        dispatch->glDisable(GL_BLEND);
+        glDisable(GL_BLEND);
     }
     else {
-        dispatch->glEnable(GL_BLEND);
-        dispatch->glBlendFunc(op_info->source_blend, op_info->dest_blend);
+        glEnable(GL_BLEND);
+        glBlendFunc(op_info->source_blend, op_info->dest_blend);
     }
 
     glamor_put_dispatch(glamor_priv);
@@ -1289,7 +1248,6 @@ glamor_composite_with_shader(CARD8 op,
     PixmapPtr dest_pixmap = dest_pixmap_priv->base.pixmap;
     PixmapPtr source_pixmap = NULL;
     PixmapPtr mask_pixmap = NULL;
-    glamor_gl_dispatch *dispatch = NULL;
     GLfloat dst_xscale, dst_yscale;
     GLfloat mask_xscale = 1, mask_yscale = 1, src_xscale = 1, src_yscale = 1;
     struct shader_key key, key_ca;
@@ -1328,7 +1286,7 @@ glamor_composite_with_shader(CARD8 op,
     glamor_set_destination_pixmap_priv_nc(dest_pixmap_priv);
     glamor_composite_set_shader_blend(dest_pixmap_priv, &key, shader, &op_info);
 
-    dispatch = glamor_get_dispatch(glamor_priv);
+    glamor_get_dispatch(glamor_priv);
 
     glamor_priv->has_source_coords = key.source != SHADER_SOURCE_SOLID;
     glamor_priv->has_mask_coords = (key.mask != SHADER_MASK_NONE &&
@@ -1445,20 +1403,20 @@ glamor_composite_with_shader(CARD8 op,
         }
     }
 
-    dispatch->glBindBuffer(GL_ARRAY_BUFFER, 0);
-    dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_MASK);
-    dispatch->glDisable(GL_BLEND);
+    glBindBuffer(GL_ARRAY_BUFFER, 0);
+    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_MASK);
+    glDisable(GL_BLEND);
 #ifndef GLAMOR_GLES2
-    dispatch->glActiveTexture(GL_TEXTURE0);
-    dispatch->glDisable(GL_TEXTURE_2D);
-    dispatch->glActiveTexture(GL_TEXTURE1);
-    dispatch->glDisable(GL_TEXTURE_2D);
+    glActiveTexture(GL_TEXTURE0);
+    glDisable(GL_TEXTURE_2D);
+    glActiveTexture(GL_TEXTURE1);
+    glDisable(GL_TEXTURE_2D);
 #endif
     DEBUGF("finish rendering.\n");
-    dispatch->glUseProgram(0);
+    glUseProgram(0);
     glamor_priv->state = RENDER_STATE;
     glamor_priv->render_idle_cnt = 0;
     if (saved_source_format)
diff --git a/glamor/glamor_tile.c b/glamor/glamor_tile.c
index 9c8e521..8ceb549 100644
--- a/glamor/glamor_tile.c
+++ b/glamor/glamor_tile.c
@@ -37,7 +37,6 @@ void
 glamor_init_tile_shader(ScreenPtr screen)
 {
     glamor_screen_private *glamor_priv;
-    glamor_gl_dispatch *dispatch;
     const char *tile_vs =
         "attribute vec4 v_position;\n"
         "attribute vec4 v_texcoord0;\n"
@@ -63,27 +62,27 @@ glamor_init_tile_shader(ScreenPtr screen)
     GLint sampler_uniform_location;
 
     glamor_priv = glamor_get_screen_private(screen);
-    dispatch = glamor_get_dispatch(glamor_priv);
-    glamor_priv->tile_prog = dispatch->glCreateProgram();
-    vs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, tile_vs);
-    fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER, tile_fs);
-    dispatch->glAttachShader(glamor_priv->tile_prog, vs_prog);
-    dispatch->glAttachShader(glamor_priv->tile_prog, fs_prog);
-
-    dispatch->glBindAttribLocation(glamor_priv->tile_prog,
-                                   GLAMOR_VERTEX_POS, "v_position");
-    dispatch->glBindAttribLocation(glamor_priv->tile_prog,
-                                   GLAMOR_VERTEX_SOURCE, "v_texcoord0");
-    glamor_link_glsl_prog(dispatch, glamor_priv->tile_prog);
+    glamor_get_dispatch(glamor_priv);
+    glamor_priv->tile_prog = glCreateProgram();
+    vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, tile_vs);
+    fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, tile_fs);
+    glAttachShader(glamor_priv->tile_prog, vs_prog);
+    glAttachShader(glamor_priv->tile_prog, fs_prog);
+
+    glBindAttribLocation(glamor_priv->tile_prog,
+                         GLAMOR_VERTEX_POS, "v_position");
+    glBindAttribLocation(glamor_priv->tile_prog,
+                         GLAMOR_VERTEX_SOURCE, "v_texcoord0");
+    glamor_link_glsl_prog(glamor_priv->tile_prog);
 
     sampler_uniform_location =
-        dispatch->glGetUniformLocation(glamor_priv->tile_prog, "sampler");
-    dispatch->glUseProgram(glamor_priv->tile_prog);
-    dispatch->glUniform1i(sampler_uniform_location, 0);
+        glGetUniformLocation(glamor_priv->tile_prog, "sampler");
+    glUseProgram(glamor_priv->tile_prog);
+    glUniform1i(sampler_uniform_location, 0);
 
     glamor_priv->tile_wh =
-        dispatch->glGetUniformLocation(glamor_priv->tile_prog, "wh");
-    dispatch->glUseProgram(0);
+        glGetUniformLocation(glamor_priv->tile_prog, "wh");
+    glUseProgram(0);
     glamor_put_dispatch(glamor_priv);
 }
 
@@ -91,11 +90,10 @@ void
 glamor_fini_tile_shader(ScreenPtr screen)
 {
     glamor_screen_private *glamor_priv;
-    glamor_gl_dispatch *dispatch;
 
     glamor_priv = glamor_get_screen_private(screen);
-    dispatch = glamor_get_dispatch(glamor_priv);
-    dispatch->glDeleteProgram(glamor_priv->tile_prog);
+    glamor_get_dispatch(glamor_priv);
+    glDeleteProgram(glamor_priv->tile_prog);
     glamor_put_dispatch(glamor_priv);
 }
 
@@ -105,7 +103,6 @@ _glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
 {
     ScreenPtr screen = pixmap->drawable.pScreen;
     glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
-    glamor_gl_dispatch *dispatch;
     int x1 = x;
     int x2 = x + width;
     int y1 = y;
@@ -127,19 +124,19 @@ _glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
     glamor_set_destination_pixmap_priv_nc(dst_pixmap_priv);
     pixmap_priv_get_dest_scale(dst_pixmap_priv, &dst_xscale, &dst_yscale);
     pixmap_priv_get_scale(src_pixmap_priv, &src_xscale, &src_yscale);
-    dispatch = glamor_get_dispatch(glamor_priv);
-    dispatch->glUseProgram(glamor_priv->tile_prog);
+    glamor_get_dispatch(glamor_priv);
+    glUseProgram(glamor_priv->tile_prog);
 
     glamor_pixmap_fbo_fix_wh_ratio(wh, src_pixmap_priv);
-    dispatch->glUniform2fv(glamor_priv->tile_wh, 1, wh);
-    dispatch->glActiveTexture(GL_TEXTURE0);
-    dispatch->glBindTexture(GL_TEXTURE_2D, src_pixmap_priv->base.fbo->tex);
-    dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-    dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-    dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
-    dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+    glUniform2fv(glamor_priv->tile_wh, 1, wh);
+    glActiveTexture(GL_TEXTURE0);
+    glBindTexture(GL_TEXTURE_2D, src_pixmap_priv->base.fbo->tex);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
 #ifndef GLAMOR_GLES2
-    dispatch->glEnable(GL_TEXTURE_2D);
+    glEnable(GL_TEXTURE_2D);
 #endif
     glamor_set_repeat_normalize_tcoords
         (src_pixmap_priv, RepeatNormal,
@@ -147,26 +144,25 @@ _glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
          tile_x1, tile_y1,
          tile_x2, tile_y2, glamor_priv->yInverted, source_texcoords);
 
-    dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
-                                    GL_FLOAT, GL_FALSE,
-                                    2 * sizeof(float), source_texcoords);
-    dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+    glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT, GL_FALSE,
+                          2 * sizeof(float), source_texcoords);
+    glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
 
     glamor_set_normalize_vcoords(dst_pixmap_priv, dst_xscale, dst_yscale,
                                  x1, y1,
                                  x2, y2, glamor_priv->yInverted, vertices);
 
-    dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
-                                    GL_FALSE, 2 * sizeof(float), vertices);
-    dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
-    dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+    glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT, GL_FALSE,
+                          2 * sizeof(float), vertices);
+    glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+    glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
 
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
 #ifndef GLAMOR_GLES2
-    dispatch->glDisable(GL_TEXTURE_2D);
+    glDisable(GL_TEXTURE_2D);
 #endif
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
-    dispatch->glUseProgram(0);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+    glUseProgram(0);
     glamor_put_dispatch(glamor_priv);
 
     glamor_priv->state = RENDER_STATE;
@@ -182,7 +178,6 @@ glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
     glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
     glamor_pixmap_private *dst_pixmap_priv;
     glamor_pixmap_private *src_pixmap_priv;
-    glamor_gl_dispatch *dispatch;
 
     dst_pixmap_priv = glamor_get_pixmap_private(pixmap);
     src_pixmap_priv = glamor_get_pixmap_private(tile);
@@ -206,8 +201,8 @@ glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
         goto fail;
     }
 
-    dispatch = glamor_get_dispatch(glamor_priv);
-    if (!glamor_set_alu(dispatch, alu)) {
+    glamor_get_dispatch(glamor_priv);
+    if (!glamor_set_alu(alu)) {
         glamor_fallback("unsupported alu %x\n", alu);
         glamor_put_dispatch(glamor_priv);
         goto fail;
@@ -302,7 +297,7 @@ glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
     else
         _glamor_tile(pixmap, tile, x, y, width, height, tile_x, tile_y);
 
-    glamor_set_alu(dispatch, GXcopy);
+    glamor_set_alu(GXcopy);
     glamor_put_dispatch(glamor_priv);
     return TRUE;
  fail:
diff --git a/glamor/glamor_trapezoid.c b/glamor/glamor_trapezoid.c
index cd99a47..b398213 100644
--- a/glamor/glamor_trapezoid.c
+++ b/glamor/glamor_trapezoid.c
@@ -204,23 +204,21 @@ static void
 glamor_flush_composite_triangles(ScreenPtr screen)
 {
     glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
-    glamor_gl_dispatch *dispatch;
 
-    dispatch = glamor_get_dispatch(glamor_priv);
+    glamor_get_dispatch(glamor_priv);
     if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP)
-        dispatch->glUnmapBuffer(GL_ARRAY_BUFFER);
+        glUnmapBuffer(GL_ARRAY_BUFFER);
     else {
 
-        dispatch->glBindBuffer(GL_ARRAY_BUFFER, glamor_priv->vbo);
-        dispatch->glBufferData(GL_ARRAY_BUFFER,
-                               glamor_priv->vbo_offset,
-                               glamor_priv->vb, GL_DYNAMIC_DRAW);
+        glBindBuffer(GL_ARRAY_BUFFER, glamor_priv->vbo);
+        glBufferData(GL_ARRAY_BUFFER, glamor_priv->vbo_offset,
+                     glamor_priv->vb, GL_DYNAMIC_DRAW);
     }
 
     if (!glamor_priv->render_nr_verts)
         return;
 
-    dispatch->glDrawArrays(GL_TRIANGLES, 0, glamor_priv->render_nr_verts);
+    glDrawArrays(GL_TRIANGLES, 0, glamor_priv->render_nr_verts);
     glamor_put_dispatch(glamor_priv);
 }
 
@@ -582,7 +580,6 @@ static void
 glamor_setup_composite_vbo_for_trapezoid(ScreenPtr screen, int n_verts)
 {
     glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
-    glamor_gl_dispatch *dispatch;
     int stride;
     int vert_size;
 
@@ -605,25 +602,25 @@ glamor_setup_composite_vbo_for_trapezoid(ScreenPtr screen, int n_verts)
 
     vert_size = n_verts * glamor_priv->vb_stride;
 
-    dispatch = glamor_get_dispatch(glamor_priv);
+    glamor_get_dispatch(glamor_priv);
 
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_TOP_BOTTOM);
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_LEFT_PARAM);
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_RIGHT_PARAM);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_TOP_BOTTOM);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_LEFT_PARAM);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_RIGHT_PARAM);
 
-    dispatch->glBindBuffer(GL_ARRAY_BUFFER, glamor_priv->vbo);
+    glBindBuffer(GL_ARRAY_BUFFER, glamor_priv->vbo);
     if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
         if (glamor_priv->vbo_size < (glamor_priv->vbo_offset + vert_size)) {
             glamor_priv->vbo_size = GLAMOR_COMPOSITE_VBO_VERT_CNT *
                 glamor_priv->vb_stride;
             glamor_priv->vbo_offset = 0;
-            dispatch->glBufferData(GL_ARRAY_BUFFER,
-                                   glamor_priv->vbo_size, NULL, GL_STREAM_DRAW);
+            glBufferData(GL_ARRAY_BUFFER,
+                         glamor_priv->vbo_size, NULL, GL_STREAM_DRAW);
         }
 
-        glamor_priv->vb = dispatch->glMapBufferRange(GL_ARRAY_BUFFER,
+        glamor_priv->vb = glMapBufferRange(GL_ARRAY_BUFFER,
                                                      glamor_priv->vbo_offset,
                                                      vert_size,
                                                      GL_MAP_WRITE_BIT |
@@ -636,41 +633,41 @@ glamor_setup_composite_vbo_for_trapezoid(ScreenPtr screen, int n_verts)
         glamor_priv->vbo_offset = 0;
     }
 
-    dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glamor_priv->ebo);
+    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glamor_priv->ebo);
 
     /* Set the vertex pointer. */
-    dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
-                                    GL_FALSE, glamor_priv->vb_stride,
-                                    (void *) ((long) glamor_priv->vbo_offset));
-    dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+    glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
+                          GL_FALSE, glamor_priv->vb_stride,
+                          (void *) ((long) glamor_priv->vbo_offset));
+    glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
     stride = 2;
 
-    dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT,
-                                    GL_FALSE, glamor_priv->vb_stride,
-                                    (void *) ((long) glamor_priv->vbo_offset +
-                                              stride * sizeof(float)));
-    dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+    glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT,
+                          GL_FALSE, glamor_priv->vb_stride,
+                          (void *) ((long) glamor_priv->vbo_offset +
+                                    stride * sizeof(float)));
+    glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
     stride += 2;
 
-    dispatch->glVertexAttribPointer(GLAMOR_VERTEX_TOP_BOTTOM, 2, GL_FLOAT,
+    glVertexAttribPointer(GLAMOR_VERTEX_TOP_BOTTOM, 2, GL_FLOAT,
                                     GL_FALSE, glamor_priv->vb_stride,
                                     (void *) ((long) glamor_priv->vbo_offset +
                                               stride * sizeof(float)));
-    dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_TOP_BOTTOM);
+    glEnableVertexAttribArray(GLAMOR_VERTEX_TOP_BOTTOM);
     stride += 2;
 
-    dispatch->glVertexAttribPointer(GLAMOR_VERTEX_LEFT_PARAM, 4, GL_FLOAT,
+    glVertexAttribPointer(GLAMOR_VERTEX_LEFT_PARAM, 4, GL_FLOAT,
                                     GL_FALSE, glamor_priv->vb_stride,
                                     (void *) ((long) glamor_priv->vbo_offset +
                                               stride * sizeof(float)));
-    dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_LEFT_PARAM);
+    glEnableVertexAttribArray(GLAMOR_VERTEX_LEFT_PARAM);
     stride += 4;
 
-    dispatch->glVertexAttribPointer(GLAMOR_VERTEX_RIGHT_PARAM, 4, GL_FLOAT,
+    glVertexAttribPointer(GLAMOR_VERTEX_RIGHT_PARAM, 4, GL_FLOAT,
                                     GL_FALSE, glamor_priv->vb_stride,
                                     (void *) ((long) glamor_priv->vbo_offset +
                                               stride * sizeof(float)));
-    dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_RIGHT_PARAM);
+    glEnableVertexAttribArray(GLAMOR_VERTEX_RIGHT_PARAM);
 
     glamor_put_dispatch(glamor_priv);
 }
@@ -701,7 +698,6 @@ _glamor_trapezoids_with_shader(CARD8 op,
     GLfloat dst_xscale, dst_yscale;
     BoxRec bounds;
     PicturePtr temp_src = src;
-    glamor_gl_dispatch *dispatch = NULL;
     int vert_stride = 3;
     int ntriangle_per_loop;
     int nclip_rect;
@@ -815,6 +811,8 @@ _glamor_trapezoids_with_shader(CARD8 op,
         goto TRAPEZOID_OUT;
     }
 
+    glamor_get_dispatch(glamor_priv);
+
     box = REGION_RECTS(&region);
     nbox = REGION_NUM_RECTS(&region);
     pbox = box;
@@ -833,8 +831,6 @@ _glamor_trapezoids_with_shader(CARD8 op,
     glamor_priv->has_mask_coords = (key.mask != SHADER_MASK_NONE &&
                                     key.mask != SHADER_MASK_SOLID);
 
-    dispatch = glamor_get_dispatch(glamor_priv);
-
     glamor_get_drawable_deltas(dst->pDrawable, dest_pixmap,
                                &dest_x_off, &dest_y_off);
 
@@ -974,19 +970,20 @@ _glamor_trapezoids_with_shader(CARD8 op,
     ret = TRUE;
 
  TRAPEZOID_RESET_GL:
-    dispatch->glBindBuffer(GL_ARRAY_BUFFER, 0);
-    dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_MASK);
-    dispatch->glDisable(GL_BLEND);
+    glBindBuffer(GL_ARRAY_BUFFER, 0);
+    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_MASK);
+    glDisable(GL_BLEND);
 #ifndef GLAMOR_GLES2
-    dispatch->glActiveTexture(GL_TEXTURE0);
-    dispatch->glDisable(GL_TEXTURE_2D);
-    dispatch->glActiveTexture(GL_TEXTURE1);
-    dispatch->glDisable(GL_TEXTURE_2D);
+    glActiveTexture(GL_TEXTURE0);
+    glDisable(GL_TEXTURE_2D);
+    glActiveTexture(GL_TEXTURE1);
+    glDisable(GL_TEXTURE_2D);
 #endif
-    dispatch->glUseProgram(0);
+    glUseProgram(0);
+    glamor_put_dispatch(glamor_priv);
 
  TRAPEZOID_OUT:
     if (box) {
@@ -1002,10 +999,6 @@ _glamor_trapezoids_with_shader(CARD8 op,
         }
     }
 
-    if (dispatch) {
-        glamor_put_dispatch(glamor_priv);
-    }
-
     return ret;
 }
 
@@ -1013,7 +1006,6 @@ void
 glamor_init_trapezoid_shader(ScreenPtr screen)
 {
     glamor_screen_private *glamor_priv;
-    glamor_gl_dispatch *dispatch;
     GLint fs_prog, vs_prog;
 
     const char *trapezoid_vs =
@@ -1344,32 +1336,30 @@ glamor_init_trapezoid_shader(ScreenPtr screen)
         "}\n";
 
     glamor_priv = glamor_get_screen_private(screen);
-    dispatch = glamor_get_dispatch(glamor_priv);
+    glamor_get_dispatch(glamor_priv);
 
-    glamor_priv->trapezoid_prog = dispatch->glCreateProgram();
+    glamor_priv->trapezoid_prog = glCreateProgram();
 
-    vs_prog = glamor_compile_glsl_prog(dispatch,
-                                       GL_VERTEX_SHADER, trapezoid_vs);
-    fs_prog = glamor_compile_glsl_prog(dispatch,
-                                       GL_FRAGMENT_SHADER, trapezoid_fs);
+    vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, trapezoid_vs);
+    fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, trapezoid_fs);
 
-    dispatch->glAttachShader(glamor_priv->trapezoid_prog, vs_prog);
-    dispatch->glAttachShader(glamor_priv->trapezoid_prog, fs_prog);
+    glAttachShader(glamor_priv->trapezoid_prog, vs_prog);
+    glAttachShader(glamor_priv->trapezoid_prog, fs_prog);
 
-    dispatch->glBindAttribLocation(glamor_priv->trapezoid_prog,
-                                   GLAMOR_VERTEX_POS, "v_positionsition");
-    dispatch->glBindAttribLocation(glamor_priv->trapezoid_prog,
-                                   GLAMOR_VERTEX_SOURCE, "v_texcoord");
-    dispatch->glBindAttribLocation(glamor_priv->trapezoid_prog,
-                                   GLAMOR_VERTEX_TOP_BOTTOM, "v_top_bottom");
-    dispatch->glBindAttribLocation(glamor_priv->trapezoid_prog,
-                                   GLAMOR_VERTEX_LEFT_PARAM, "v_left_param");
-    dispatch->glBindAttribLocation(glamor_priv->trapezoid_prog,
-                                   GLAMOR_VERTEX_RIGHT_PARAM, "v_right_param");
+    glBindAttribLocation(glamor_priv->trapezoid_prog,
+                         GLAMOR_VERTEX_POS, "v_positionsition");
+    glBindAttribLocation(glamor_priv->trapezoid_prog,
+                         GLAMOR_VERTEX_SOURCE, "v_texcoord");
+    glBindAttribLocation(glamor_priv->trapezoid_prog,
+                         GLAMOR_VERTEX_TOP_BOTTOM, "v_top_bottom");
+    glBindAttribLocation(glamor_priv->trapezoid_prog,
+                         GLAMOR_VERTEX_LEFT_PARAM, "v_left_param");
+    glBindAttribLocation(glamor_priv->trapezoid_prog,
+                         GLAMOR_VERTEX_RIGHT_PARAM, "v_right_param");
 
-    glamor_link_glsl_prog(dispatch, glamor_priv->trapezoid_prog);
+    glamor_link_glsl_prog(glamor_priv->trapezoid_prog);
 
-    dispatch->glUseProgram(0);
+    glUseProgram(0);
 
     glamor_put_dispatch(glamor_priv);
 }
@@ -1378,11 +1368,10 @@ void
 glamor_fini_trapezoid_shader(ScreenPtr screen)
 {
     glamor_screen_private *glamor_priv;
-    glamor_gl_dispatch *dispatch;
 
     glamor_priv = glamor_get_screen_private(screen);
-    dispatch = glamor_get_dispatch(glamor_priv);
-    dispatch->glDeleteProgram(glamor_priv->trapezoid_prog);
+    glamor_get_dispatch(glamor_priv);
+    glDeleteProgram(glamor_priv->trapezoid_prog);
     glamor_put_dispatch(glamor_priv);
 }
 
@@ -1392,7 +1381,6 @@ _glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture,
                                        BoxRec *bounds)
 {
     glamor_screen_private *glamor_priv;
-    glamor_gl_dispatch *dispatch;
     glamor_pixmap_private *pixmap_priv;
     PixmapPtr pixmap = NULL;
     GLint trapezoid_prog;
@@ -1425,20 +1413,20 @@ _glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture,
         return FALSE;
     }
 
-    dispatch = glamor_get_dispatch(glamor_priv);
+    glamor_get_dispatch(glamor_priv);
 
     glamor_set_destination_pixmap_priv_nc(pixmap_priv);
 
     pixmap_priv_get_dest_scale(pixmap_priv, (&xscale), (&yscale));
 
-    dispatch->glBindBuffer(GL_ARRAY_BUFFER, 0);
-    dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+    glBindBuffer(GL_ARRAY_BUFFER, 0);
+    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
 
     /* Now draw the Trapezoid mask. */
-    dispatch->glUseProgram(trapezoid_prog);
+    glUseProgram(trapezoid_prog);
 
-    dispatch->glEnable(GL_BLEND);
-    dispatch->glBlendFunc(GL_ONE, GL_ONE);
+    glEnable(GL_BLEND);
+    glBlendFunc(GL_ONE, GL_ONE);
 
     nrect_max = GLAMOR_COMPOSITE_VBO_VERT_CNT / (4 * GLAMOR_VERTEX_RIGHT_PARAM);
 
@@ -1565,36 +1553,35 @@ _glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture,
             continue;
 
         if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP)
-            dispatch->glUnmapBuffer(GL_ARRAY_BUFFER);
+            glUnmapBuffer(GL_ARRAY_BUFFER);
         else {
-            dispatch->glBindBuffer(GL_ARRAY_BUFFER, glamor_priv->vbo);
-            dispatch->glBufferData(GL_ARRAY_BUFFER,
-                                   glamor_priv->vbo_offset,
-                                   glamor_priv->vb, GL_DYNAMIC_DRAW);
+            glBindBuffer(GL_ARRAY_BUFFER, glamor_priv->vbo);
+            glBufferData(GL_ARRAY_BUFFER, glamor_priv->vbo_offset,
+                         glamor_priv->vb, GL_DYNAMIC_DRAW);
         }
 
 #ifndef GLAMOR_GLES2
-        dispatch->glDrawRangeElements(GL_TRIANGLES, 0,
-                                      glamor_priv->render_nr_verts,
-                                      (glamor_priv->render_nr_verts * 3) / 2,
-                                      GL_UNSIGNED_SHORT, NULL);
+        glDrawRangeElements(GL_TRIANGLES, 0,
+                            glamor_priv->render_nr_verts,
+                            (glamor_priv->render_nr_verts * 3) / 2,
+                            GL_UNSIGNED_SHORT, NULL);
 #else
-        dispatch->glDrawElements(GL_TRIANGLES,
-                                 (glamor_priv->render_nr_verts * 3) / 2,
-                                 GL_UNSIGNED_SHORT, NULL);
+        glDrawElements(GL_TRIANGLES,
+                       (glamor_priv->render_nr_verts * 3) / 2,
+                       GL_UNSIGNED_SHORT, NULL);
 #endif
     }
 
-    dispatch->glBindBuffer(GL_ARRAY_BUFFER, 0);
-    dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
-    dispatch->glBlendFunc(GL_ONE, GL_ZERO);
-    dispatch->glDisable(GL_BLEND);
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_TOP_BOTTOM);
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_LEFT_PARAM);
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_RIGHT_PARAM);
-    dispatch->glUseProgram(0);
+    glBindBuffer(GL_ARRAY_BUFFER, 0);
+    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+    glBlendFunc(GL_ONE, GL_ZERO);
+    glDisable(GL_BLEND);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_TOP_BOTTOM);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_LEFT_PARAM);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_RIGHT_PARAM);
+    glUseProgram(0);
     glamor_put_dispatch(glamor_priv);
     return TRUE;
 }
diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h
index ea827df..d427360 100644
--- a/glamor/glamor_utils.h
+++ b/glamor/glamor_utils.h
@@ -1828,13 +1828,11 @@ glamor_restore_current(ScreenPtr screen)
     glamor_egl_restore_context(screen);
 }
 
-static inline glamor_gl_dispatch *
+static inline void
 glamor_get_dispatch(glamor_screen_private * glamor_priv)
 {
     if (glamor_priv->flags & GLAMOR_USE_EGL_SCREEN)
         glamor_make_current(glamor_priv->screen);
-
-    return &glamor_priv->_dispatch;
 }
 
 static inline void
diff --git a/glamor/glamor_xv.c b/glamor/glamor_xv.c
index cbe07c8..89787a4 100644
--- a/glamor/glamor_xv.c
+++ b/glamor/glamor_xv.c
@@ -90,23 +90,22 @@ void
 glamor_init_xv_shader(ScreenPtr screen)
 {
     glamor_screen_private *glamor_priv;
-    glamor_gl_dispatch *dispatch;
     GLint fs_prog, vs_prog;
 
     glamor_priv = glamor_get_screen_private(screen);
-    dispatch = glamor_get_dispatch(glamor_priv);
-    glamor_priv->xv_prog = dispatch->glCreateProgram();
+    glamor_get_dispatch(glamor_priv);
+    glamor_priv->xv_prog = glCreateProgram();
 
-    vs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, xv_vs);
-    fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER, xv_ps);
-    dispatch->glAttachShader(glamor_priv->xv_prog, vs_prog);
-    dispatch->glAttachShader(glamor_priv->xv_prog, fs_prog);
+    vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, xv_vs);
+    fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, xv_ps);
+    glAttachShader(glamor_priv->xv_prog, vs_prog);
+    glAttachShader(glamor_priv->xv_prog, fs_prog);
 
-    dispatch->glBindAttribLocation(glamor_priv->xv_prog,
-                                   GLAMOR_VERTEX_POS, "v_position");
-    dispatch->glBindAttribLocation(glamor_priv->xv_prog,
-                                   GLAMOR_VERTEX_SOURCE, "v_texcoord0");
-    glamor_link_glsl_prog(dispatch, glamor_priv->xv_prog);
+    glBindAttribLocation(glamor_priv->xv_prog,
+                         GLAMOR_VERTEX_POS, "v_position");
+    glBindAttribLocation(glamor_priv->xv_prog,
+                         GLAMOR_VERTEX_SOURCE, "v_texcoord0");
+    glamor_link_glsl_prog(glamor_priv->xv_prog);
 
     glamor_put_dispatch(glamor_priv);
 }
@@ -115,12 +114,11 @@ void
 glamor_fini_xv_shader(ScreenPtr screen)
 {
     glamor_screen_private *glamor_priv;
-    glamor_gl_dispatch *dispatch;
 
     glamor_priv = glamor_get_screen_private(screen);
-    dispatch = glamor_get_dispatch(glamor_priv);
+    glamor_get_dispatch(glamor_priv);
 
-    dispatch->glDeleteProgram(glamor_priv->xv_prog);
+    glDeleteProgram(glamor_priv->xv_prog);
     glamor_put_dispatch(glamor_priv);
 }
 
@@ -278,7 +276,6 @@ glamor_display_textured_video(glamor_port_private *port_priv)
     glamor_pixmap_private *pixmap_priv =
         glamor_get_pixmap_private(port_priv->pPixmap);
     glamor_pixmap_private *src_pixmap_priv[3];
-    glamor_gl_dispatch *dispatch;
     float vertices[32], texcoords[8];
     BoxPtr box = REGION_RECTS(&port_priv->clip);
     int nBox = REGION_NUM_RECTS(&port_priv->clip);
@@ -327,62 +324,53 @@ glamor_display_textured_video(glamor_port_private *port_priv)
                                   &src_yscale[i]);
         }
     }
-    dispatch = glamor_get_dispatch(glamor_priv);
-    dispatch->glUseProgram(glamor_priv->xv_prog);
-
-    uloc = dispatch->glGetUniformLocation(glamor_priv->xv_prog, "offsetyco");
-    dispatch->glUniform4f(uloc, off[0], off[1], off[2], yco);
-    uloc = dispatch->glGetUniformLocation(glamor_priv->xv_prog, "ucogamma");
-    dispatch->glUniform4f(uloc, uco[0], uco[1], uco[2], gamma);
-    uloc = dispatch->glGetUniformLocation(glamor_priv->xv_prog, "vco");
-    dispatch->glUniform4f(uloc, vco[0], vco[1], vco[2], 0);
-
-    dispatch->glActiveTexture(GL_TEXTURE0);
-    dispatch->glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[0]->base.fbo->tex);
-    dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-    dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-    dispatch->glTexParameteri(GL_TEXTURE_2D,
-                              GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-    dispatch->glTexParameteri(GL_TEXTURE_2D,
-                              GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
-    dispatch->glActiveTexture(GL_TEXTURE1);
-    dispatch->glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[1]->base.fbo->tex);
-    dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-    dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-    dispatch->glTexParameteri(GL_TEXTURE_2D,
-                              GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-    dispatch->glTexParameteri(GL_TEXTURE_2D,
-                              GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
-    dispatch->glActiveTexture(GL_TEXTURE2);
-    dispatch->glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[2]->base.fbo->tex);
-    dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-    dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-    dispatch->glTexParameteri(GL_TEXTURE_2D,
-                              GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-    dispatch->glTexParameteri(GL_TEXTURE_2D,
-                              GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
-    sampler_loc =
-        dispatch->glGetUniformLocation(glamor_priv->xv_prog, "y_sampler");
-    dispatch->glUniform1i(sampler_loc, 0);
-    sampler_loc =
-        dispatch->glGetUniformLocation(glamor_priv->xv_prog, "u_sampler");
-    dispatch->glUniform1i(sampler_loc, 1);
-    sampler_loc =
-        dispatch->glGetUniformLocation(glamor_priv->xv_prog, "v_sampler");
-    dispatch->glUniform1i(sampler_loc, 2);
-
-    dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
-                                    GL_FLOAT, GL_FALSE,
-                                    2 * sizeof(float), texcoords);
-    dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
-
-    dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
-                                    GL_FALSE, 2 * sizeof(float), vertices);
-
-    dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+    glamor_get_dispatch(glamor_priv);
+    glUseProgram(glamor_priv->xv_prog);
+
+    uloc = glGetUniformLocation(glamor_priv->xv_prog, "offsetyco");
+    glUniform4f(uloc, off[0], off[1], off[2], yco);
+    uloc = glGetUniformLocation(glamor_priv->xv_prog, "ucogamma");
+    glUniform4f(uloc, uco[0], uco[1], uco[2], gamma);
+    uloc = glGetUniformLocation(glamor_priv->xv_prog, "vco");
+    glUniform4f(uloc, vco[0], vco[1], vco[2], 0);
+
+    glActiveTexture(GL_TEXTURE0);
+    glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[0]->base.fbo->tex);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+    glActiveTexture(GL_TEXTURE1);
+    glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[1]->base.fbo->tex);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+    glActiveTexture(GL_TEXTURE2);
+    glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[2]->base.fbo->tex);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+    sampler_loc = glGetUniformLocation(glamor_priv->xv_prog, "y_sampler");
+    glUniform1i(sampler_loc, 0);
+    sampler_loc = glGetUniformLocation(glamor_priv->xv_prog, "u_sampler");
+    glUniform1i(sampler_loc, 1);
+    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_SOURCE);
+
+    glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
+                          GL_FALSE, 2 * sizeof(float), vertices);
+
+    glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
     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;
@@ -418,13 +406,13 @@ glamor_display_textured_video(glamor_port_private *port_priv)
                                      srcy + srch,
                                      glamor_priv->yInverted, texcoords);
 
-        dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+        glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
     }
 
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
-    dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+    glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
 
-    dispatch->glUseProgram(0);
+    glUseProgram(0);
     glamor_put_dispatch(glamor_priv);
     DamageDamageRegion(port_priv->pDraw, &port_priv->clip);
 }
-- 
1.9.rc1



More information about the xorg-devel mailing list