From 281f26a1dfda732687680a36857960f74608df5b Mon Sep 17 00:00:00 2001
From: marha <marha@users.sourceforge.net>
Date: Thu, 25 Oct 2012 09:59:33 +0200
Subject: fontconfig mesa pixman git update

fonconfig: 73ab254336100c5971e3a1e14b73222efd0e9822
mesa: 86cd77d0a9ac940c2c06eebc5e9ef840d176712a
pixman: 9df645dfb04b5a790faabe1e9a84fc37287d91b0
---
 mesalib/bin/get-pick-list.sh                       |  29 +++
 mesalib/configure.ac                               |  10 +-
 mesalib/docs/GL3.txt                               |   2 +-
 mesalib/docs/index.html                            |   8 +
 mesalib/docs/relnotes-8.0.5.html                   | 264 +++++++++++++++++++++
 mesalib/docs/relnotes.html                         |   1 +
 mesalib/scons/gallium.py                           |   2 +-
 mesalib/src/mapi/glapi/gen/GL3x.xml                |   5 +-
 mesalib/src/mesa/main/api_exec.c                   |  45 ++--
 mesalib/src/mesa/main/api_loopback.h               |   1 +
 mesalib/src/mesa/main/bufferobj.c                  |   3 +
 mesalib/src/mesa/main/dlist.c                      |   5 +-
 mesalib/src/mesa/main/pack.c                       | 216 ++++++++---------
 mesalib/src/mesa/main/queryobj.c                   |  45 +++-
 mesalib/src/mesa/main/queryobj.h                   |   3 +-
 mesalib/src/mesa/main/samplerobj.c                 |  14 +-
 mesalib/src/mesa/main/samplerobj.h                 |   3 +-
 mesalib/src/mesa/main/transformfeedback.c          |   7 +-
 mesalib/src/mesa/main/transformfeedback.h          |   3 +-
 mesalib/src/mesa/main/uniforms.c                   |  18 +-
 mesalib/src/mesa/state_tracker/st_cb_texture.c     |   5 +-
 mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp |  21 +-
 mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c   |  12 +-
 23 files changed, 545 insertions(+), 177 deletions(-)
 create mode 100644 mesalib/bin/get-pick-list.sh
 create mode 100644 mesalib/docs/relnotes-8.0.5.html

(limited to 'mesalib')

diff --git a/mesalib/bin/get-pick-list.sh b/mesalib/bin/get-pick-list.sh
new file mode 100644
index 000000000..72880907b
--- /dev/null
+++ b/mesalib/bin/get-pick-list.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+# Script for generating a list of candidates for cherry-picking to a stable branch
+
+# Grep for commits with "cherry picked from commit" in the commit message.
+git log --reverse --grep="cherry picked from commit" origin/master..HEAD |\
+	grep "cherry picked from commit" |\
+	sed -e 's/^[[:space:]]*(cherry picked from commit[[:space:]]*//' -e 's/)//' > already_picked
+
+# Grep for commits that were marked as a candidate for the stable tree.
+git log --reverse --pretty=%H -i --grep='^[[:space:]]*NOTE: This is a candidate' HEAD..origin/master |\
+while read sha
+do
+	# Check to see whether the patch is on the ignore list.
+	if [ -f .git/cherry-ignore ] ; then
+		if grep -q ^$sha .git/cherry-ignore ; then
+			continue
+		fi
+	fi
+
+	# Check to see if it has already been picked over.
+	if grep -q ^$sha already_picked ; then
+		continue
+	fi
+
+	git log -n1 --pretty=oneline $sha | cat
+done
+
+rm -f already_picked
diff --git a/mesalib/configure.ac b/mesalib/configure.ac
index 94392910f..6b97a26fc 100644
--- a/mesalib/configure.ac
+++ b/mesalib/configure.ac
@@ -160,13 +160,13 @@ DEFINES=""
 AC_SUBST([DEFINES])
 case "$host_os" in
 linux*|*-gnu*|gnu*)
-    DEFINES="$DEFINES -D_GNU_SOURCE"
+    DEFINES="$DEFINES -D_GNU_SOURCE -DHAVE_PTHREAD"
     ;;
 solaris*)
-    DEFINES="$DEFINES -DSVR4"
+    DEFINES="$DEFINES -DHAVE_PTHREAD -DSVR4"
     ;;
 cygwin*)
-    DEFINES="$DEFINES"
+    DEFINES="$DEFINES -DHAVE_PTHREAD"
     ;;
 esac
 
@@ -946,7 +946,7 @@ AC_ARG_ENABLE([glx-tls],
 AC_SUBST(GLX_TLS, ${GLX_USE_TLS})
 
 AS_IF([test "x$GLX_USE_TLS" = xyes -a "x$ax_pthread_ok" = xyes],
-      [DEFINES="${DEFINES} -DGLX_USE_TLS"])
+      [DEFINES="${DEFINES} -DGLX_USE_TLS -DHAVE_PTHREAD"])
 
 dnl
 dnl More DRI setup
@@ -1030,7 +1030,7 @@ if test "x$enable_dri" = xyes; then
         esac
         ;;
     freebsd* | dragonfly* | *netbsd*)
-        DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1"
+        DEFINES="$DEFINES -DHAVE_PTHREAD -DUSE_EXTERNAL_DXTN_LIB=1"
         DEFINES="$DEFINES -DIN_DRI_DRIVER -DHAVE_ALIAS"
 
         if test "x$DRI_DIRS" = "xyes"; then
diff --git a/mesalib/docs/GL3.txt b/mesalib/docs/GL3.txt
index 876165fe9..4efe4bfeb 100644
--- a/mesalib/docs/GL3.txt
+++ b/mesalib/docs/GL3.txt
@@ -120,7 +120,7 @@ GLSL 4.2                                             not started
 GL_ARB_texture_compression_bptc                      not started
 GL_ARB_compressed_texture_pixel_storage              not started
 GL_ARB_shader_atomic_counters                        not started
-GL_ARB_texture_storage                               DONE (r300, r600, swrast)
+GL_ARB_texture_storage                               DONE (r300, r600, swrast, gallium)
 GL_ARB_transform_feedback_instanced                  DONE
 GL_ARB_base_instance                                 DONE (nv50, nvc0, r600, radeonsi)
 GL_ARB_shader_image_load_store                       not started
diff --git a/mesalib/docs/index.html b/mesalib/docs/index.html
index ac4ff8d9e..ba0b21044 100644
--- a/mesalib/docs/index.html
+++ b/mesalib/docs/index.html
@@ -16,6 +16,14 @@
 
 <h1>News</h1>
 
+<h2>October 24, 2012</h2>
+
+<p>
+<a href="relnotes-8.0.5.html">Mesa 8.0.5</a> is released.
+This is a bug fix release.
+</p>
+
+
 <h2>October 8, 2012</h2>
 
 <p>
diff --git a/mesalib/docs/relnotes-8.0.5.html b/mesalib/docs/relnotes-8.0.5.html
new file mode 100644
index 000000000..eb7595bb3
--- /dev/null
+++ b/mesalib/docs/relnotes-8.0.5.html
@@ -0,0 +1,264 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html lang="en">
+<head>
+  <meta http-equiv="content-type" content="text/html; charset=utf-8">
+  <title>Mesa Release Notes</title>
+  <link rel="stylesheet" type="text/css" href="mesa.css">
+</head>
+<body>
+
+<div class="header">
+  <h1>The Mesa 3D Graphics Library</h1>
+</div>
+
+<iframe src="contents.html"></iframe>
+<div class="content">
+
+<h1>Mesa 8.0.5 Release Notes / October 24, 2012</h1>
+
+<p>
+Mesa 8.0.5 is a bug fix release which fixes bugs found since the 8.0.4 release.
+</p>
+<p>
+Mesa 8.0.5 implements the OpenGL 3.0 API, but the version reported by
+glGetString(GL_VERSION) depends on the particular driver being used.
+Some drivers don't support all the features required in OpenGL 3.0.
+</p>
+<p>
+See the <a href="install.html">Compiling/Installing page</a> for prerequisites
+for DRI hardware acceleration.
+</p>
+
+
+<h2>MD5 checksums</h2>
+<pre>
+cda5d101f43b8784fa60bdeaca4056f2  MesaLib-8.0.5.tar.gz
+01305591073a76b65267f69f27d635a3  MesaLib-8.0.5.tar.bz2
+97f11c00cac8fb98aa0131990086dc8e  MesaLib-8.0.5.zip
+</pre>
+
+<h2>New features</h2>
+<p>None.</p>
+
+<h2>Bug fixes</h2>
+
+<p>This list is likely incomplete.</p>
+
+<ul>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=44912">Bug 44912</a> - [bisected] WebGL conformance/textures/texture-mips tests fails</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=46644">Bug 46644</a> - Sandybridge Mobile: ARBfp TXP with coords from fragment.color doesn't apply W divide</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=46784">Bug 46784</a> - MAD using multiply written register fails</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=47375">Bug 47375</a> - Blender crash on startup after upgrade to mesa 8.0.1</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=48120">Bug 48120</a> - GL_EXT_texture_sRGB_decode still broken</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=48628">Bug 48628</a> - [bisected ILK]Oglc fogexp(basic.allCases) regressed</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=49772">Bug 49772</a> - [SNB]Oglc depth-stencil(basic.read.ds) regressed</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=52129">Bug 52129</a> - [Bisected ILK]Piglit spec_ARB_shader_texture_lod_execution_glsl-fs-shadow2DGradARB-01  regressed</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=52382">Bug 52382</a> - [ivb gt1] Severe image corruption and GPU Hang, too many PS threads</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=52563">Bug 52563</a> - build failure - struct radeon_renderbuffer has no member named Base</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=53311">Bug 53311</a> - [Bisected IVB]Oglc transform_feedback(advanced.transformFeedback.points) Invalid argument</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=53314">Bug 53314</a> - [llvmpipe] src/gallium/drivers/llvmpipe/lp_texture.c:920:llvmpipe_get_texture_tile_layout: Assertion `x &lt; lpr-&gt;tiles_per_row[level]' failed.</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=53316">Bug 53316</a> - [llvmpipe] src/gallium/drivers/llvmpipe/lp_texture.c:601:llvmpipe_get_transfer: Assertion `resource' failed.</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=53317">Bug 53317</a> - [llvmpipe] SIGSEGV src/gallium/auxiliary/gallivm/lp_bld_sample.c:99</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=53318">Bug 53318</a> - [softpipe] sp_state_shader.c:194:softpipe_delete_fs_state: Assertion `var != softpipe-&gt;fs_variant' failed.</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=53319">Bug 53319</a> - [softpipe] sp_texture.c:322:softpipe_get_transfer: Assertion `level &lt;= resource-&gt;last_level' failed.</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=53618">Bug 53618</a> - [Bisected i915]Piglit glx_GLX_ARB_create_context_NULL_attribute_list Aborted</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=53972">Bug 53972</a> - Black Mirror III: too dark</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=54183">Bug 54183</a> - [Bisected ILK regression]many piglit/oglc/ogles2 cases Segmentation fault</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=54193">Bug 54193</a> - output_components uninitialized in fs_visitor::emit_fb_writes()</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=54301">Bug 54301</a> - [Bisected ILK regression]Piglit glx_GLX_ARB_create_context_forward-compatible_flag_with_3.0 Segmentation fault</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=56211">Bug 56211</a> - src/mesa/state_tracker/st_cb_texture.c:1123:copy_image_data_to_texture: Assertion `u_minify(stImage-&gt;pt-&gt;height0, src_level) == stImage-&gt;base.Height' failed.</li>
+
+<!-- <li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=">Bug </a> - </li> -->
+
+</ul>
+
+
+<h2>Changes</h2>
+<p>The full set of changes can be viewed by using the following GIT command:</p>
+
+<pre>
+  git log mesa-8.0.4..mesa-8.0.5
+</pre>
+
+<p>Alex Deucher (3):</p>
+<ul>
+  <li>r600g: 8.0.x support for Trinity</li>
+  <li>r600g: add new Sumo, Palm, BTC pci ids</li>
+  <li>r600g: add additional evergreen pci ids</li>
+</ul>
+
+<p>Andreas Boll (4):</p>
+<ul>
+  <li>docs/relnotes-8.0.4: fix html markup</li>
+  <li>mesa: fix html in shortlog_mesa.sh script</li>
+  <li>mesa: add get-pick-list.sh script into bin/</li>
+  <li>mesa: Bump version number to 8.0.5</li>
+</ul>
+
+<p>Brian Paul (18):</p>
+<ul>
+  <li>mesa: use _mesa_is_user_fbo() and _mesa_is_winsys_fbo() functions</li>
+  <li>intel: use _mesa_is_winsys/user_fbo() helpers</li>
+  <li>st/egl: fix uninitialized pointer bug</li>
+  <li>mesa: added Ian's shortlog_mesa.sh script in bin/</li>
+  <li>mesa: loosen small matrix determinant check</li>
+  <li>xlib: add X error handler around XGetImage() call</li>
+  <li>radeon: set swrast_renderbuffer::ColorType field when mapping renderbuffers</li>
+  <li>svga: fix invalid memory reference in needs_to_create_zero()</li>
+  <li>meta: fix glDrawPixels fallback test, stencil drawing</li>
+  <li>radeon: fix Base/base typo</li>
+  <li>st/mesa: fix glCopyTexSubImage crash</li>
+  <li>gallivm: fix crash in lp_sampler_static_state()</li>
+  <li>st/mesa: fix renderbuffer validation bug</li>
+  <li>softpipe: fix softpipe_delete_fs_state() failed assertion</li>
+  <li>mesa: raise GL_INVALID_OPERATION in glGenerateMipmap for missing base image</li>
+  <li>st/mesa: s/CALLOC/calloc/ to fix allocation bug</li>
+  <li>mesa: do internal format error checking for glTexStorage()</li>
+  <li>mesa: fix incorrect error for glCompressedSubTexImage</li>
+</ul>
+
+<p>Chad Versace (3):</p>
+<ul>
+  <li>mesa: Don't advertise GLES extensions in GL contexts</li>
+  <li>i830: Fix stack corruption</li>
+  <li>swrast: Fix implicit declaration warnings</li>
+</ul>
+
+<p>Chris Forbes (1):</p>
+<ul>
+  <li>mesa: fix dropped &amp;&amp; in glGetStringi()</li>
+</ul>
+
+<p>Christoph Bumiller (1):</p>
+<ul>
+  <li>st/mesa: call update_renderbuffer_surface for sRGB renderbuffers, too</li>
+</ul>
+
+<p>Eric Anholt (9):</p>
+<ul>
+  <li>i965/gen7: Reduce GT1 WM thread count according to updated BSpec.</li>
+  <li>i965/fs: Invalidate live intervals in passes that remove an instruction.</li>
+  <li>i965: Fix bug in the old FS backend's projtex() calculation.</li>
+  <li>i965: Add support for GL_SKIP_DECODE_EXT on other SRGB formats.</li>
+  <li>i965/vs: Convert EdgeFlagPointer values appropriately for the VS on gen4.</li>
+  <li>i965: Fix accumulator_contains() test to also reject swizzles of the dst.</li>
+  <li>mesa: Fix glPopAttrib() behavior on GL_FRAMEBUFFER_SRGB.</li>
+  <li>mesa: In conditional rendering fallback, check the query status.</li>
+  <li>i965: Drop the confusing saturate argument to math instruction setup.</li>
+</ul>
+
+<p>Ian Romanick (8):</p>
+<ul>
+  <li>docs: Add 8.0.4 release md5sums</li>
+  <li>Revert "i965: Avoid unnecessary recompiles for shaders that don't use dFdy()."</li>
+  <li>i965: Fix regression in depth texture rendering on pre-SNB</li>
+  <li>dri2: Fix bug in attribute handling for non-desktop OpenGL contexts</li>
+  <li>mesa: Generate an error when glCopyTexImage border is invalid</li>
+  <li>mesa/es: Validate glTexImage border in Mesa code rather than the ES wrapper</li>
+  <li>mesa: Allow glGetTexParameter of GL_TEXTURE_SRGB_DECODE_EXT</li>
+  <li>dri_util: Use calloc to allocate __DRIcontext</li>
+</ul>
+
+<p>Jonas Maebe (1):</p>
+<ul>
+  <li>darwin: do not create double-buffered offscreen pixel formats</li>
+</ul>
+
+<p>Jordan Justen (1):</p>
+<ul>
+  <li>intel: move error on create context to proper path</li>
+</ul>
+
+<p>José Fonseca (1):</p>
+<ul>
+  <li>mesa: disable MSVC global optimization in pack.c</li>
+</ul>
+
+<p>Kenneth Graunke (8):</p>
+<ul>
+  <li>mesa: Use GLdouble for depthMax in final unpack conversions.</li>
+  <li>i965/fs: Initialize output_components[] by filling it with zeros.</li>
+  <li>mesa: Prevent repeated glDeleteShader() from blowing away our refcounts.</li>
+  <li>i965: Support MESA_FORMAT_SIGNED_RGBA_16.</li>
+  <li>glsl: Fix #pragma invariant(all) language version check.</li>
+  <li>i965/vs: Don't clobber sampler message MRFs with subexpressions.</li>
+  <li>intel: Move finish_batch() call before MI_BATCH_BUFFER_END and padding.</li>
+  <li>i965/fs: Don't use brw-&gt;fragment_program in calculate_urb_setup().</li>
+</ul>
+
+<p>Maarten Lankhorst (1):</p>
+<ul>
+  <li>winsys/radeon: Remove unnecessary pipe_thread_destroy in radeon_drm_cs_destroy</li>
+</ul>
+
+<p>Marek Olšák (6):</p>
+<ul>
+  <li>mesa: remove assertions that do not allow compressed 2D_ARRAY textures</li>
+  <li>r300g: fix colormask with non-BGRA formats</li>
+  <li>r600g: fix RSQ of negative value on Cayman</li>
+  <li>r600g: fix EXP on Cayman</li>
+  <li>r600g: fix instance divisor on Cayman</li>
+  <li>gallium/u_blit: set dst format from pipe_resource, not pipe_surface</li>
+</ul>
+
+<p>Michel Dänzer (2):</p>
+<ul>
+  <li>st/mesa: Fix source miptree level for copying data to finalized miptree.</li>
+  <li>st/mesa: Fix assertions for copying texture image to finalized miptree.</li>
+</ul>
+
+<p>Niels Ole Salscheider (1):</p>
+<ul>
+  <li>st/mesa: index can be negative in the PROGRAM_CONSTANT case</li>
+</ul>
+
+<p>Paul Berry (5):</p>
+<ul>
+  <li>i965: Compute dFdy() correctly for FBOs.</li>
+  <li>mesa: Add UsesDFdy to struct gl_fragment_program.</li>
+  <li>i965: Avoid unnecessary recompiles for shaders that don't use dFdy().</li>
+  <li>i965/Gen6: Work around GPU hangs due to misaligned depth coordinate offsets.</li>
+  <li>i965/Gen7: Work around GPU hangs due to misaligned depth coordinate offsets.</li>
+</ul>
+
+<p>Stéphane Marchesin (1):</p>
+<ul>
+  <li>glsl/linker: Avoid buffer over-run in parcel_out_uniform_storage::visit_field</li>
+</ul>
+
+<p>Tapani Pälli (2):</p>
+<ul>
+  <li>xmlconfig: use __progname when building for Android</li>
+  <li>android: do not expose single buffered eglconfigs</li>
+</ul>
+
+<p>Vadim Girlin (1):</p>
+<ul>
+  <li>winsys/radeon: fix relocs caching</li>
+</ul>
+
+</div>
+</body>
+</html>
diff --git a/mesalib/docs/relnotes.html b/mesalib/docs/relnotes.html
index 62b7b33ee..ab8a70671 100644
--- a/mesalib/docs/relnotes.html
+++ b/mesalib/docs/relnotes.html
@@ -23,6 +23,7 @@ The release notes summarize what's new or changed in each Mesa release.
 <ul>
 <li><a href="relnotes-9.1.html">9.1 release notes</a>
 <li><a href="relnotes-9.0.html">9.0 release notes</a>
+<li><a href="relnotes-8.0.5.html">8.0.5 release notes</a>
 <li><a href="relnotes-8.0.4.html">8.0.4 release notes</a>
 <li><a href="relnotes-8.0.3.html">8.0.3 release notes</a>
 <li><a href="relnotes-8.0.2.html">8.0.2 release notes</a>
diff --git a/mesalib/scons/gallium.py b/mesalib/scons/gallium.py
index c3f33a05a..bba3f0179 100644
--- a/mesalib/scons/gallium.py
+++ b/mesalib/scons/gallium.py
@@ -368,7 +368,7 @@ def generate(env):
             ccflags += ['-m64']
             if platform == 'darwin':
                 ccflags += ['-fno-common']
-        if env['platform'] not in ('windows', 'haiku'):
+        if env['platform'] not in ('cygwin', 'haiku', 'windows'):
             ccflags += ['-fvisibility=hidden']
         # See also:
         # - http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
diff --git a/mesalib/src/mapi/glapi/gen/GL3x.xml b/mesalib/src/mapi/glapi/gen/GL3x.xml
index 7642a27c4..82b977f58 100644
--- a/mesalib/src/mapi/glapi/gen/GL3x.xml
+++ b/mesalib/src/mapi/glapi/gen/GL3x.xml
@@ -150,7 +150,7 @@
       <return type="const GLubyte *"/>
   </function>
 
-  <function name="ClampColor" offset="assign">
+  <function name="ClampColor" alias="ClampColorARB">
     <param name="target" type="GLenum"/>
     <param name="clamp" type="GLenum"/>
   </function>
@@ -624,7 +624,8 @@
   <enum name="TEXTURE_SWIZZLE_A"                value="0x8E45"/>
   <enum name="TEXTURE_SWIZZLE_RGBA"             value="0x8E46"/>
 
-  <function name="VertexAttribDivisor" offset="assign" es2="3.0">
+  <function name="VertexAttribDivisor" offset="assign" es2="3.0"
+            alias="VertexAttribDivisorARB">
     <param name="index" type="GLuint"/>
     <param name="divisor" type="GLuint"/>
   </function>
diff --git a/mesalib/src/mesa/main/api_exec.c b/mesalib/src/mesa/main/api_exec.c
index d2f14ce1a..a670fba43 100644
--- a/mesalib/src/mesa/main/api_exec.c
+++ b/mesalib/src/mesa/main/api_exec.c
@@ -322,10 +322,12 @@ _mesa_create_exec_table(struct gl_context *ctx)
       SET_DisableClientState(exec, _mesa_DisableClientState);
       SET_EdgeFlagPointer(exec, _mesa_EdgeFlagPointer);
       SET_EnableClientState(exec, _mesa_EnableClientState);
-      SET_GetPointerv(exec, _mesa_GetPointerv);
       SET_IndexPointer(exec, _mesa_IndexPointer);
       SET_InterleavedArrays(exec, _mesa_InterleavedArrays);
    }
+   if (ctx->API != API_OPENGLES2) {
+      SET_GetPointerv(exec, _mesa_GetPointerv);
+   }
    SET_IsTexture(exec, _mesa_IsTexture);
    if (ctx->API != API_OPENGL_CORE && ctx->API != API_OPENGLES2) {
       SET_NormalPointer(exec, _mesa_NormalPointer);
@@ -490,8 +492,8 @@ _mesa_create_exec_table(struct gl_context *ctx)
 
    /* 352. GL_EXT_transform_feedback */
    /* ARB 93. GL_ARB_transform_feedback2 */
-   if (ctx->API != API_OPENGLES2) {
-      _mesa_init_transform_feedback_dispatch(exec);
+   if (ctx->API != API_OPENGLES2 || _mesa_is_gles3(ctx)) {
+      _mesa_init_transform_feedback_dispatch(ctx, exec);
    }
 
    /* 364. GL_EXT_provoking_vertex */
@@ -578,13 +580,15 @@ _mesa_create_exec_table(struct gl_context *ctx)
    SET_EnableVertexAttribArrayARB(exec, _mesa_EnableVertexAttribArrayARB);
    SET_DisableVertexAttribArrayARB(exec, _mesa_DisableVertexAttribArrayARB);
    if (ctx->API != API_OPENGLES2) {
-      SET_ProgramStringARB(exec, _mesa_ProgramStringARB);
       /* glBindProgramARB aliases glBindProgramNV */
       /* glDeleteProgramsARB aliases glDeleteProgramsNV */
       /* glGenProgramsARB aliases glGenProgramsNV */
       /* glIsProgramARB aliases glIsProgramNV */
       SET_GetVertexAttribdvARB(exec, _mesa_GetVertexAttribdvARB);
    }
+   if (ctx->API == API_OPENGL) {
+      SET_ProgramStringARB(exec, _mesa_ProgramStringARB);
+   }
 
    SET_GetVertexAttribfvARB(exec, _mesa_GetVertexAttribfvARB);
    SET_GetVertexAttribivARB(exec, _mesa_GetVertexAttribivARB);
@@ -610,15 +614,15 @@ _mesa_create_exec_table(struct gl_context *ctx)
    _mesa_init_bufferobj_dispatch(ctx, exec);
 
    /* ARB 29. GL_ARB_occlusion_query */
-   if (ctx->API != API_OPENGLES2) {
-      _mesa_init_queryobj_dispatch(exec);
+   if (ctx->API != API_OPENGLES2 || _mesa_is_gles3(ctx)) {
+      _mesa_init_queryobj_dispatch(ctx, exec);
    }
 
    /* ARB 37. GL_ARB_draw_buffers */
    SET_DrawBuffersARB(exec, _mesa_DrawBuffersARB);
 
    /* ARB 66. GL_ARB_sync */
-   if (ctx->API != API_OPENGLES2) {
+   if (ctx->API != API_OPENGLES2 || _mesa_is_gles3(ctx)) {
       _mesa_init_sync_dispatch(exec);
    }
 
@@ -668,7 +672,7 @@ _mesa_create_exec_table(struct gl_context *ctx)
    SET_GetFramebufferAttachmentParameterivEXT(exec, _mesa_GetFramebufferAttachmentParameterivEXT);
    SET_GenerateMipmapEXT(exec, _mesa_GenerateMipmapEXT);
 
-   if (ctx->API != API_OPENGLES2) {
+   if (ctx->API != API_OPENGLES2 || _mesa_is_gles3(ctx)) {
       SET_BlitFramebufferEXT(exec, _mesa_BlitFramebufferEXT);
    }
 
@@ -679,7 +683,7 @@ _mesa_create_exec_table(struct gl_context *ctx)
    }
 
    /* GL_MESA_texture_array / GL_EXT_texture_array */
-   if (ctx->API != API_OPENGLES2) {
+   if (ctx->API != API_OPENGLES2 || _mesa_is_gles3(ctx)) {
       SET_FramebufferTextureLayerEXT(exec, _mesa_FramebufferTextureLayerEXT);
    }
 
@@ -691,7 +695,7 @@ _mesa_create_exec_table(struct gl_context *ctx)
    /* The ARB_fbo functions are the union of
     * GL_EXT_fbo, GL_EXT_framebuffer_blit, GL_EXT_texture_array
     */
-   if (ctx->API != API_OPENGLES2) {
+   if (ctx->API != API_OPENGLES2 || _mesa_is_gles3(ctx)) {
       SET_RenderbufferStorageMultisample(exec, _mesa_RenderbufferStorageMultisample);
    }
 
@@ -700,7 +704,7 @@ _mesa_create_exec_table(struct gl_context *ctx)
    SET_FlushMappedBufferRange(exec, _mesa_FlushMappedBufferRange);
 
    /* GL_ARB_copy_buffer */
-   if (ctx->API != API_OPENGLES2) {
+   if (ctx->API != API_OPENGLES2 || _mesa_is_gles3(ctx)) {
       SET_CopyBufferSubData(exec, _mesa_CopyBufferSubData);
    }
 
@@ -710,9 +714,11 @@ _mesa_create_exec_table(struct gl_context *ctx)
 
    /* GL_EXT_draw_buffers2 */
    if (_mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx)) {
+      SET_GetIntegerIndexedvEXT(exec, _mesa_GetIntegerIndexedv);
+   }
+   if (_mesa_is_desktop_gl(ctx)) {
       SET_ColorMaskIndexedEXT(exec, _mesa_ColorMaskIndexed);
       SET_GetBooleanIndexedvEXT(exec, _mesa_GetBooleanIndexedv);
-      SET_GetIntegerIndexedvEXT(exec, _mesa_GetIntegerIndexedv);
       SET_EnableIndexedEXT(exec, _mesa_EnableIndexed);
       SET_DisableIndexedEXT(exec, _mesa_DisableIndexed);
       SET_IsEnabledIndexedEXT(exec, _mesa_IsEnabledIndexed);
@@ -743,7 +749,7 @@ _mesa_create_exec_table(struct gl_context *ctx)
    }
 
    /* GL_EXT_texture_integer */
-   if (_mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx)) {
+   if (_mesa_is_desktop_gl(ctx)) {
       SET_ClearColorIiEXT(exec, _mesa_ClearColorIiEXT);
       SET_ClearColorIuiEXT(exec, _mesa_ClearColorIuiEXT);
    }
@@ -755,24 +761,23 @@ _mesa_create_exec_table(struct gl_context *ctx)
    }
 
    /* GL_EXT_gpu_shader4 / OpenGL 3.0 */
-   if (ctx->API != API_OPENGLES2) {
+   if (ctx->API != API_OPENGLES2 || _mesa_is_gles3(ctx)) {
       SET_GetVertexAttribIivEXT(exec, _mesa_GetVertexAttribIiv);
       SET_GetVertexAttribIuivEXT(exec, _mesa_GetVertexAttribIuiv);
       SET_VertexAttribIPointerEXT(exec, _mesa_VertexAttribIPointer);
    }
 
    /* GL 3.0 (functions not covered by other extensions) */
-   if (ctx->API != API_OPENGLES2) {
+   if (ctx->API != API_OPENGLES2 || _mesa_is_gles3(ctx)) {
       SET_ClearBufferiv(exec, _mesa_ClearBufferiv);
       SET_ClearBufferuiv(exec, _mesa_ClearBufferuiv);
       SET_ClearBufferfv(exec, _mesa_ClearBufferfv);
       SET_ClearBufferfi(exec, _mesa_ClearBufferfi);
       SET_GetStringi(exec, _mesa_GetStringi);
-      SET_ClampColor(exec, _mesa_ClampColorARB);
    }
 
    /* GL_ARB_instanced_arrays */
-   if (ctx->API != API_OPENGLES2) {
+   if (ctx->API != API_OPENGLES2 || _mesa_is_gles3(ctx)) {
       SET_VertexAttribDivisorARB(exec, _mesa_VertexAttribDivisor);
    }
 
@@ -802,12 +807,14 @@ _mesa_create_exec_table(struct gl_context *ctx)
    if (_mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx)) {
       SET_TexStorage2D(exec, _mesa_TexStorage2D);
       SET_TexStorage3D(exec, _mesa_TexStorage3D);
+   }
+   if (_mesa_is_desktop_gl(ctx)) {
       SET_TextureStorage2DEXT(exec, _mesa_TextureStorage2DEXT);
       SET_TextureStorage3DEXT(exec, _mesa_TextureStorage3DEXT);
    }
 
-   if (ctx->API != API_OPENGLES2) {
-      _mesa_init_sampler_object_dispatch(exec);
+   if (ctx->API != API_OPENGLES2 || _mesa_is_gles3(ctx)) {
+      _mesa_init_sampler_object_dispatch(ctx, exec);
    }
 
    if (_mesa_is_desktop_gl(ctx)) {
diff --git a/mesalib/src/mesa/main/api_loopback.h b/mesalib/src/mesa/main/api_loopback.h
index 3e43286d2..628d4f89e 100644
--- a/mesalib/src/mesa/main/api_loopback.h
+++ b/mesalib/src/mesa/main/api_loopback.h
@@ -31,6 +31,7 @@
 #include "main/mfeatures.h"
 
 struct _glapi_table;
+struct gl_context;
 
 extern void
 _mesa_loopback_init_api_table(const struct gl_context *ctx,
diff --git a/mesalib/src/mesa/main/bufferobj.c b/mesalib/src/mesa/main/bufferobj.c
index ac6bbc56b..ac58c99d9 100644
--- a/mesalib/src/mesa/main/bufferobj.c
+++ b/mesalib/src/mesa/main/bufferobj.c
@@ -2341,6 +2341,9 @@ _mesa_init_bufferobj_dispatch(struct gl_context *ctx, struct _glapi_table *disp)
    SET_DeleteBuffersARB(disp, _mesa_DeleteBuffersARB);
    SET_GenBuffersARB(disp, _mesa_GenBuffersARB);
    SET_GetBufferParameterivARB(disp, _mesa_GetBufferParameterivARB);
+   /* TODO: add GetBufferParameteri64v for desktop GL and GLES3 once tests
+    * exist for it.
+    */
    SET_GetBufferPointervARB(disp, _mesa_GetBufferPointervARB);
    if (ctx->API != API_OPENGLES2) {
       SET_GetBufferSubDataARB(disp, _mesa_GetBufferSubDataARB);
diff --git a/mesalib/src/mesa/main/dlist.c b/mesalib/src/mesa/main/dlist.c
index 28cd52a40..d53879efd 100644
--- a/mesalib/src/mesa/main/dlist.c
+++ b/mesalib/src/mesa/main/dlist.c
@@ -10060,7 +10060,7 @@ _mesa_create_save_table(const struct gl_context *ctx)
    SET_MapBufferARB(table, _mesa_MapBufferARB);
    SET_UnmapBufferARB(table, _mesa_UnmapBufferARB);
 
-   _mesa_init_queryobj_dispatch(table); /* glGetQuery, etc */
+   _mesa_init_queryobj_dispatch(ctx, table); /* glGetQuery, etc */
    SET_BeginQueryARB(table, save_BeginQueryARB);
    SET_EndQueryARB(table, save_EndQueryARB);
    SET_QueryCounter(table, save_QueryCounter);
@@ -10143,7 +10143,6 @@ _mesa_create_save_table(const struct gl_context *ctx)
 
    /* GL_ARB_color_buffer_float */
    SET_ClampColorARB(table, save_ClampColorARB);
-   SET_ClampColor(table, save_ClampColorARB);
 
    /* GL 3.0 */
    SET_ClearBufferiv(table, save_ClearBufferiv);
@@ -10197,7 +10196,7 @@ _mesa_create_save_table(const struct gl_context *ctx)
    SET_TextureBarrierNV(table, save_TextureBarrierNV);
 
    /* GL_ARB_sampler_objects */
-   _mesa_init_sampler_object_dispatch(table); /* plug in Gen/Get/etc functions */
+   _mesa_init_sampler_object_dispatch(ctx, table); /* plug in Gen/Get/etc functions */
    SET_BindSampler(table, save_BindSampler);
    SET_SamplerParameteri(table, save_SamplerParameteri);
    SET_SamplerParameterf(table, save_SamplerParameterf);
diff --git a/mesalib/src/mesa/main/pack.c b/mesalib/src/mesa/main/pack.c
index a23bc998d..4f0caa763 100644
--- a/mesalib/src/mesa/main/pack.c
+++ b/mesalib/src/mesa/main/pack.c
@@ -557,9 +557,9 @@ _mesa_pack_rgba_span_from_uints(struct gl_context *ctx, GLuint n, GLuint rgba[][
       if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER)) {
          GLubyte *dst = (GLubyte *) dstAddr;
          for (i=0;i<n;i++) {
-            dst[i] = (CLAMP(rgba[i][RCOMP], 0, 7) << 5)
-                   | (CLAMP(rgba[i][GCOMP], 0, 7) << 2)
-                   | (CLAMP(rgba[i][BCOMP], 0, 3)     );
+            dst[i] = (MIN2(rgba[i][RCOMP], 7) << 5)
+                   | (MIN2(rgba[i][GCOMP], 7) << 2)
+                   | (MIN2(rgba[i][BCOMP], 3)     );
          }
       } else {
          _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
@@ -569,9 +569,9 @@ _mesa_pack_rgba_span_from_uints(struct gl_context *ctx, GLuint n, GLuint rgba[][
       if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER)) {
          GLubyte *dst = (GLubyte *) dstAddr;
          for (i=0;i<n;i++) {
-            dst[i] = (CLAMP(rgba[i][RCOMP], 0, 7)     )
-                   | (CLAMP(rgba[i][GCOMP], 0, 7) << 3)
-                   | (CLAMP(rgba[i][BCOMP], 0, 3) << 6);
+            dst[i] = (MIN2(rgba[i][RCOMP], 7)     )
+                   | (MIN2(rgba[i][GCOMP], 7) << 3)
+                   | (MIN2(rgba[i][BCOMP], 3) << 6);
          }
       } else {
          _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
@@ -581,9 +581,9 @@ _mesa_pack_rgba_span_from_uints(struct gl_context *ctx, GLuint n, GLuint rgba[][
       if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER)) {
          GLushort *dst = (GLushort *) dstAddr;
          for (i=0;i<n;i++) {
-            dst[i] = (CLAMP(rgba[i][RCOMP], 0, 31) << 11)
-                   | (CLAMP(rgba[i][GCOMP], 0, 63) <<  5)
-                   | (CLAMP(rgba[i][BCOMP], 0, 31)      );
+            dst[i] = (MIN2(rgba[i][RCOMP], 31) << 11)
+                   | (MIN2(rgba[i][GCOMP], 63) <<  5)
+                   | (MIN2(rgba[i][BCOMP], 31)      );
          }
       } else {
          _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
@@ -593,9 +593,9 @@ _mesa_pack_rgba_span_from_uints(struct gl_context *ctx, GLuint n, GLuint rgba[][
       if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER)) {
          GLushort *dst = (GLushort *) dstAddr;
          for (i=0;i<n;i++) {
-            dst[i] = (CLAMP(rgba[i][RCOMP], 0, 31)      )
-                   | (CLAMP(rgba[i][GCOMP], 0, 63) <<  5)
-                   | (CLAMP(rgba[i][BCOMP], 0, 31) << 11);
+            dst[i] = (MIN2(rgba[i][RCOMP], 31)      )
+                   | (MIN2(rgba[i][GCOMP], 63) <<  5)
+                   | (MIN2(rgba[i][BCOMP], 31) << 11);
          }
       } else {
          _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
@@ -605,28 +605,28 @@ _mesa_pack_rgba_span_from_uints(struct gl_context *ctx, GLuint n, GLuint rgba[][
       if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) {
          GLushort *dst = (GLushort *) dstAddr;
          for (i=0;i<n;i++) {
-            dst[i] = (CLAMP(rgba[i][RCOMP], 0, 15) << 12)
-                   | (CLAMP(rgba[i][GCOMP], 0, 15) <<  8)
-                   | (CLAMP(rgba[i][BCOMP], 0, 15) <<  4)
-                   | (CLAMP(rgba[i][ACOMP], 0, 15)      );
+            dst[i] = (MIN2(rgba[i][RCOMP], 15) << 12)
+                   | (MIN2(rgba[i][GCOMP], 15) <<  8)
+                   | (MIN2(rgba[i][BCOMP], 15) <<  4)
+                   | (MIN2(rgba[i][ACOMP], 15)      );
          }
       }
       else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) {
          GLushort *dst = (GLushort *) dstAddr;
          for (i=0;i<n;i++) {
-            dst[i] = (CLAMP(rgba[i][BCOMP], 0, 15) << 12)
-                   | (CLAMP(rgba[i][GCOMP], 0, 15) <<  8)
-                   | (CLAMP(rgba[i][RCOMP], 0, 15) <<  4)
-                   | (CLAMP(rgba[i][ACOMP], 0, 15)      );
+            dst[i] = (MIN2(rgba[i][BCOMP], 15) << 12)
+                   | (MIN2(rgba[i][GCOMP], 15) <<  8)
+                   | (MIN2(rgba[i][RCOMP], 15) <<  4)
+                   | (MIN2(rgba[i][ACOMP], 15)      );
          }
       }
       else if (dstFormat == GL_ABGR_EXT) {
          GLushort *dst = (GLushort *) dstAddr;
          for (i=0;i<n;i++) {
-            dst[i] = (CLAMP(rgba[i][ACOMP], 0, 15) << 12)
-                   | (CLAMP(rgba[i][BCOMP], 0, 15) <<  8)
-                   | (CLAMP(rgba[i][GCOMP], 0, 15) <<  4)
-                   | (CLAMP(rgba[i][RCOMP], 0, 15)      );
+            dst[i] = (MIN2(rgba[i][ACOMP], 15) << 12)
+                   | (MIN2(rgba[i][BCOMP], 15) <<  8)
+                   | (MIN2(rgba[i][GCOMP], 15) <<  4)
+                   | (MIN2(rgba[i][RCOMP], 15)      );
          }
       } else {
          _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
@@ -636,28 +636,28 @@ _mesa_pack_rgba_span_from_uints(struct gl_context *ctx, GLuint n, GLuint rgba[][
       if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) {
          GLushort *dst = (GLushort *) dstAddr;
          for (i=0;i<n;i++) {
-            dst[i] = (CLAMP(rgba[i][RCOMP], 0, 15)      )
-                   | (CLAMP(rgba[i][GCOMP], 0, 15) <<  4)
-                   | (CLAMP(rgba[i][BCOMP], 0, 15) <<  8)
-                   | (CLAMP(rgba[i][ACOMP], 0, 15) << 12);
+            dst[i] = (MIN2(rgba[i][RCOMP], 15)      )
+                   | (MIN2(rgba[i][GCOMP], 15) <<  4)
+                   | (MIN2(rgba[i][BCOMP], 15) <<  8)
+                   | (MIN2(rgba[i][ACOMP], 15) << 12);
          }
       }
       else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) {
          GLushort *dst = (GLushort *) dstAddr;
          for (i=0;i<n;i++) {
-            dst[i] = (CLAMP(rgba[i][BCOMP], 0, 15)      )
-                   | (CLAMP(rgba[i][GCOMP], 0, 15) <<  4)
-                   | (CLAMP(rgba[i][RCOMP], 0, 15) <<  8)
-                   | (CLAMP(rgba[i][ACOMP], 0, 15) << 12);
+            dst[i] = (MIN2(rgba[i][BCOMP], 15)      )
+                   | (MIN2(rgba[i][GCOMP], 15) <<  4)
+                   | (MIN2(rgba[i][RCOMP], 15) <<  8)
+                   | (MIN2(rgba[i][ACOMP], 15) << 12);
          }
       }
       else if (dstFormat == GL_ABGR_EXT) {
          GLushort *dst = (GLushort *) dstAddr;
          for (i=0;i<n;i++) {
-            dst[i] = (CLAMP(rgba[i][ACOMP], 0, 15)      )
-                   | (CLAMP(rgba[i][BCOMP], 0, 15) <<  4)
-                   | (CLAMP(rgba[i][GCOMP], 0, 15) <<  8)
-                   | (CLAMP(rgba[i][RCOMP], 0, 15) << 12);
+            dst[i] = (MIN2(rgba[i][ACOMP], 15)      )
+                   | (MIN2(rgba[i][BCOMP], 15) <<  4)
+                   | (MIN2(rgba[i][GCOMP], 15) <<  8)
+                   | (MIN2(rgba[i][RCOMP], 15) << 12);
          }
       } else {
          _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
@@ -667,28 +667,28 @@ _mesa_pack_rgba_span_from_uints(struct gl_context *ctx, GLuint n, GLuint rgba[][
       if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) {
          GLushort *dst = (GLushort *) dstAddr;
          for (i=0;i<n;i++) {
-            dst[i] = (CLAMP(rgba[i][RCOMP], 0, 31) << 11)
-                   | (CLAMP(rgba[i][GCOMP], 0, 31) <<  6)
-                   | (CLAMP(rgba[i][BCOMP], 0, 31) <<  1)
-                   | (CLAMP(rgba[i][ACOMP], 0,  1)      );
+            dst[i] = (MIN2(rgba[i][RCOMP], 31) << 11)
+                   | (MIN2(rgba[i][GCOMP], 31) <<  6)
+                   | (MIN2(rgba[i][BCOMP], 31) <<  1)
+                   | (MIN2(rgba[i][ACOMP],  1)      );
          }
       }
       else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) {
          GLushort *dst = (GLushort *) dstAddr;
          for (i=0;i<n;i++) {
-            dst[i] = (CLAMP(rgba[i][BCOMP], 0, 31) << 11)
-                   | (CLAMP(rgba[i][GCOMP], 0, 31) <<  6)
-                   | (CLAMP(rgba[i][RCOMP], 0, 31) <<  1)
-                   | (CLAMP(rgba[i][ACOMP], 0,  1)      );
+            dst[i] = (MIN2(rgba[i][BCOMP], 31) << 11)
+                   | (MIN2(rgba[i][GCOMP], 31) <<  6)
+                   | (MIN2(rgba[i][RCOMP], 31) <<  1)
+                   | (MIN2(rgba[i][ACOMP],  1)      );
          }
       }
       else if (dstFormat == GL_ABGR_EXT) {
          GLushort *dst = (GLushort *) dstAddr;
          for (i=0;i<n;i++) {
-            dst[i] = (CLAMP(rgba[i][ACOMP], 0, 31) << 11)
-                   | (CLAMP(rgba[i][BCOMP], 0, 31) <<  6)
-                   | (CLAMP(rgba[i][GCOMP], 0, 31) <<  1)
-                   | (CLAMP(rgba[i][RCOMP], 0,  1)      );
+            dst[i] = (MIN2(rgba[i][ACOMP], 31) << 11)
+                   | (MIN2(rgba[i][BCOMP], 31) <<  6)
+                   | (MIN2(rgba[i][GCOMP], 31) <<  1)
+                   | (MIN2(rgba[i][RCOMP],  1)      );
          }
       } else {
          _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
@@ -698,28 +698,28 @@ _mesa_pack_rgba_span_from_uints(struct gl_context *ctx, GLuint n, GLuint rgba[][
       if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) {
          GLushort *dst = (GLushort *) dstAddr;
          for (i=0;i<n;i++) {
-            dst[i] = (CLAMP(rgba[i][RCOMP], 0, 31)      )
-                   | (CLAMP(rgba[i][GCOMP], 0, 31) <<  5)
-                   | (CLAMP(rgba[i][BCOMP], 0, 31) << 10)
-                   | (CLAMP(rgba[i][ACOMP], 0,  1) << 15);
+            dst[i] = (MIN2(rgba[i][RCOMP], 31)      )
+                   | (MIN2(rgba[i][GCOMP], 31) <<  5)
+                   | (MIN2(rgba[i][BCOMP], 31) << 10)
+                   | (MIN2(rgba[i][ACOMP],  1) << 15);
          }
       }
       else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) {
          GLushort *dst = (GLushort *) dstAddr;
          for (i=0;i<n;i++) {
-            dst[i] = (CLAMP(rgba[i][BCOMP], 0, 31)      )
-                   | (CLAMP(rgba[i][GCOMP], 0, 31) <<  5)
-                   | (CLAMP(rgba[i][RCOMP], 0, 31) << 10)
-                   | (CLAMP(rgba[i][ACOMP], 0,  1) << 15);
+            dst[i] = (MIN2(rgba[i][BCOMP], 31)      )
+                   | (MIN2(rgba[i][GCOMP], 31) <<  5)
+                   | (MIN2(rgba[i][RCOMP], 31) << 10)
+                   | (MIN2(rgba[i][ACOMP],  1) << 15);
          }
       }
       else if (dstFormat == GL_ABGR_EXT) {
          GLushort *dst = (GLushort *) dstAddr;
          for (i=0;i<n;i++) {
-            dst[i] = (CLAMP(rgba[i][ACOMP], 0, 31)      )
-                   | (CLAMP(rgba[i][BCOMP], 0, 31) <<  5)
-                   | (CLAMP(rgba[i][GCOMP], 0, 31) << 10)
-                   | (CLAMP(rgba[i][RCOMP], 0,  1) << 15);
+            dst[i] = (MIN2(rgba[i][ACOMP], 31)      )
+                   | (MIN2(rgba[i][BCOMP], 31) <<  5)
+                   | (MIN2(rgba[i][GCOMP], 31) << 10)
+                   | (MIN2(rgba[i][RCOMP],  1) << 15);
          }
       } else {
          _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
@@ -729,28 +729,28 @@ _mesa_pack_rgba_span_from_uints(struct gl_context *ctx, GLuint n, GLuint rgba[][
       if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) {
          GLuint *dst = (GLuint *) dstAddr;
          for (i=0;i<n;i++) {
-            dst[i] = (CLAMP(rgba[i][RCOMP], 0, 255) << 24)
-                   | (CLAMP(rgba[i][GCOMP], 0, 255) << 16)
-                   | (CLAMP(rgba[i][BCOMP], 0, 255) <<  8)
-                   | (CLAMP(rgba[i][ACOMP], 0, 255)      );
+            dst[i] = (MIN2(rgba[i][RCOMP], 255) << 24)
+                   | (MIN2(rgba[i][GCOMP], 255) << 16)
+                   | (MIN2(rgba[i][BCOMP], 255) <<  8)
+                   | (MIN2(rgba[i][ACOMP], 255)      );
          }
       }
       else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) {
          GLuint *dst = (GLuint *) dstAddr;
          for (i=0;i<n;i++) {
-            dst[i] = (CLAMP(rgba[i][BCOMP], 0, 255) << 24)
-                   | (CLAMP(rgba[i][GCOMP], 0, 255) << 16)
-                   | (CLAMP(rgba[i][RCOMP], 0, 255) <<  8)
-                   | (CLAMP(rgba[i][ACOMP], 0, 255)      );
+            dst[i] = (MIN2(rgba[i][BCOMP], 255) << 24)
+                   | (MIN2(rgba[i][GCOMP], 255) << 16)
+                   | (MIN2(rgba[i][RCOMP], 255) <<  8)
+                   | (MIN2(rgba[i][ACOMP], 255)      );
          }
       }
       else if (dstFormat == GL_ABGR_EXT) {
          GLuint *dst = (GLuint *) dstAddr;
          for (i=0;i<n;i++) {
-            dst[i] = (CLAMP(rgba[i][ACOMP], 0, 255) << 24)
-                   | (CLAMP(rgba[i][BCOMP], 0, 255) << 16)
-                   | (CLAMP(rgba[i][GCOMP], 0, 255) <<  8)
-                   | (CLAMP(rgba[i][RCOMP], 0, 255)      );
+            dst[i] = (MIN2(rgba[i][ACOMP], 255) << 24)
+                   | (MIN2(rgba[i][BCOMP], 255) << 16)
+                   | (MIN2(rgba[i][GCOMP], 255) <<  8)
+                   | (MIN2(rgba[i][RCOMP], 255)      );
          }
       } else {
          _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
@@ -760,28 +760,28 @@ _mesa_pack_rgba_span_from_uints(struct gl_context *ctx, GLuint n, GLuint rgba[][
       if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) {
          GLuint *dst = (GLuint *) dstAddr;
          for (i=0;i<n;i++) {
-            dst[i] = (CLAMP(rgba[i][RCOMP], 0, 255)      )
-                   | (CLAMP(rgba[i][GCOMP], 0, 255) <<  8)
-                   | (CLAMP(rgba[i][BCOMP], 0, 255) << 16)
-                   | (CLAMP(rgba[i][ACOMP], 0, 255) << 24);
+            dst[i] = (MIN2(rgba[i][RCOMP], 255)      )
+                   | (MIN2(rgba[i][GCOMP], 255) <<  8)
+                   | (MIN2(rgba[i][BCOMP], 255) << 16)
+                   | (MIN2(rgba[i][ACOMP], 255) << 24);
          }
       }
       else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) {
          GLuint *dst = (GLuint *) dstAddr;
          for (i=0;i<n;i++) {
-            dst[i] = (CLAMP(rgba[i][BCOMP], 0, 255)      )
-                   | (CLAMP(rgba[i][GCOMP], 0, 255) <<  8)
-                   | (CLAMP(rgba[i][RCOMP], 0, 255) << 16)
-                   | (CLAMP(rgba[i][ACOMP], 0, 255) << 24);
+            dst[i] = (MIN2(rgba[i][BCOMP], 255)      )
+                   | (MIN2(rgba[i][GCOMP], 255) <<  8)
+                   | (MIN2(rgba[i][RCOMP], 255) << 16)
+                   | (MIN2(rgba[i][ACOMP], 255) << 24);
          }
       }
       else if (dstFormat == GL_ABGR_EXT) {
          GLuint *dst = (GLuint *) dstAddr;
          for (i=0;i<n;i++) {
-            dst[i] = (CLAMP(rgba[i][ACOMP], 0, 255)      )
-                   | (CLAMP(rgba[i][BCOMP], 0, 255) <<  8)
-                   | (CLAMP(rgba[i][GCOMP], 0, 255) << 16)
-                   | (CLAMP(rgba[i][RCOMP], 0, 255) << 24);
+            dst[i] = (MIN2(rgba[i][ACOMP], 255)      )
+                   | (MIN2(rgba[i][BCOMP], 255) <<  8)
+                   | (MIN2(rgba[i][GCOMP], 255) << 16)
+                   | (MIN2(rgba[i][RCOMP], 255) << 24);
          }
       } else {
          _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
@@ -791,28 +791,28 @@ _mesa_pack_rgba_span_from_uints(struct gl_context *ctx, GLuint n, GLuint rgba[][
       if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) {
          GLuint *dst = (GLuint *) dstAddr;
          for (i=0;i<n;i++) {
-            dst[i] = (CLAMP(rgba[i][RCOMP], 0, 1023) << 22)
-                   | (CLAMP(rgba[i][GCOMP], 0, 1023) << 12)
-                   | (CLAMP(rgba[i][BCOMP], 0, 1023) <<  2)
-                   | (CLAMP(rgba[i][ACOMP], 0,    3)      );
+            dst[i] = (MIN2(rgba[i][RCOMP], 1023) << 22)
+                   | (MIN2(rgba[i][GCOMP], 1023) << 12)
+                   | (MIN2(rgba[i][BCOMP], 1023) <<  2)
+                   | (MIN2(rgba[i][ACOMP],    3)      );
          }
       }
       else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) {
          GLuint *dst = (GLuint *) dstAddr;
          for (i=0;i<n;i++) {
-            dst[i] = (CLAMP(rgba[i][BCOMP], 0, 1023) << 22)
-                   | (CLAMP(rgba[i][GCOMP], 0, 1023) << 12)
-                   | (CLAMP(rgba[i][RCOMP], 0, 1023) <<  2)
-                   | (CLAMP(rgba[i][ACOMP], 0,    3)      );
+            dst[i] = (MIN2(rgba[i][BCOMP], 1023) << 22)
+                   | (MIN2(rgba[i][GCOMP], 1023) << 12)
+                   | (MIN2(rgba[i][RCOMP], 1023) <<  2)
+                   | (MIN2(rgba[i][ACOMP],    3)      );
          }
       }
       else if (dstFormat == GL_ABGR_EXT) {
          GLuint *dst = (GLuint *) dstAddr;
          for (i=0;i<n;i++) {
-            dst[i] = (CLAMP(rgba[i][ACOMP], 0, 1023) << 22)
-                   | (CLAMP(rgba[i][BCOMP], 0, 1023) << 12)
-                   | (CLAMP(rgba[i][GCOMP], 0, 1023) <<  2)
-                   | (CLAMP(rgba[i][RCOMP], 0,    3)      );
+            dst[i] = (MIN2(rgba[i][ACOMP], 1023) << 22)
+                   | (MIN2(rgba[i][BCOMP], 1023) << 12)
+                   | (MIN2(rgba[i][GCOMP], 1023) <<  2)
+                   | (MIN2(rgba[i][RCOMP],    3)      );
          }
       } else {
          _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
@@ -822,28 +822,28 @@ _mesa_pack_rgba_span_from_uints(struct gl_context *ctx, GLuint n, GLuint rgba[][
       if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) {
          GLuint *dst = (GLuint *) dstAddr;
          for (i=0;i<n;i++) {
-            dst[i] = (CLAMP(rgba[i][RCOMP], 0, 1023)      )
-                   | (CLAMP(rgba[i][GCOMP], 0, 1023) << 10)
-                   | (CLAMP(rgba[i][BCOMP], 0, 1023) << 20)
-                   | (CLAMP(rgba[i][ACOMP], 0,    3) << 30);
+            dst[i] = (MIN2(rgba[i][RCOMP], 1023)      )
+                   | (MIN2(rgba[i][GCOMP], 1023) << 10)
+                   | (MIN2(rgba[i][BCOMP], 1023) << 20)
+                   | (MIN2(rgba[i][ACOMP],    3) << 30);
          }
       }
       else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) {
          GLuint *dst = (GLuint *) dstAddr;
          for (i=0;i<n;i++) {
-            dst[i] = (CLAMP(rgba[i][BCOMP], 0, 1023)      )
-                   | (CLAMP(rgba[i][GCOMP], 0, 1023) << 10)
-                   | (CLAMP(rgba[i][RCOMP], 0, 1023) << 20)
-                   | (CLAMP(rgba[i][ACOMP], 0,    3) << 30);
+            dst[i] = (MIN2(rgba[i][BCOMP], 1023)      )
+                   | (MIN2(rgba[i][GCOMP], 1023) << 10)
+                   | (MIN2(rgba[i][RCOMP], 1023) << 20)
+                   | (MIN2(rgba[i][ACOMP],    3) << 30);
          }
       }
       else if (dstFormat == GL_ABGR_EXT) {
          GLuint *dst = (GLuint *) dstAddr;
          for (i=0;i<n;i++) {
-            dst[i] = (CLAMP(rgba[i][ACOMP], 0, 1023)      )
-                   | (CLAMP(rgba[i][BCOMP], 0, 1023) << 10)
-                   | (CLAMP(rgba[i][GCOMP], 0, 1023) << 20)
-                   | (CLAMP(rgba[i][RCOMP], 0,    3) << 30);
+            dst[i] = (MIN2(rgba[i][ACOMP], 1023)      )
+                   | (MIN2(rgba[i][BCOMP], 1023) << 10)
+                   | (MIN2(rgba[i][GCOMP], 1023) << 20)
+                   | (MIN2(rgba[i][RCOMP],    3) << 30);
          }
       } else {
          _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
diff --git a/mesalib/src/mesa/main/queryobj.c b/mesalib/src/mesa/main/queryobj.c
index 18792cf6c..d21691328 100644
--- a/mesalib/src/mesa/main/queryobj.c
+++ b/mesalib/src/mesa/main/queryobj.c
@@ -301,6 +301,19 @@ _mesa_BeginQueryIndexed(GLenum target, GLuint index, GLuint id)
       return;
    }
 
+   /* From the GL_ARB_occlusion_query spec:
+    *
+    *     "If BeginQueryARB is called while another query is already in
+    *      progress with the same target, an INVALID_OPERATION error is
+    *      generated."
+    */
+   if (*bindpt) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glBeginQuery{Indexed}(target=%s is active)",
+                  _mesa_lookup_enum_by_nr(target));
+      return;
+   }
+
    if (id == 0) {
       _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginQuery{Indexed}(id==0)");
       return;
@@ -361,6 +374,16 @@ _mesa_EndQueryIndexed(GLenum target, GLuint index)
 
    /* XXX should probably refcount query objects */
    q = *bindpt;
+
+   /* Check for GL_ANY_SAMPLES_PASSED vs GL_SAMPLES_PASSED. */
+   if (q && q->Target != target) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glEndQuery(target=%s with active query of target %s)",
+                  _mesa_lookup_enum_by_nr(target),
+                  _mesa_lookup_enum_by_nr(q->Target));
+      return;
+   }
+
    *bindpt = NULL;
 
    if (!q || !q->Active) {
@@ -509,7 +532,7 @@ _mesa_GetQueryIndexediv(GLenum target, GLuint index, GLenum pname,
          }
          break;
       case GL_CURRENT_QUERY_ARB:
-         *params = q ? q->Id : 0;
+         *params = (q && q->Target == target) ? q->Id : 0;
          break;
       default:
          _mesa_error(ctx, GL_INVALID_ENUM, "glGetQuery{Indexed}iv(pname)");
@@ -708,7 +731,8 @@ _mesa_GetQueryObjectui64vEXT(GLuint id, GLenum pname, GLuint64EXT *params)
 
 
 void
-_mesa_init_queryobj_dispatch(struct _glapi_table *disp)
+_mesa_init_queryobj_dispatch(const struct gl_context *ctx,
+                             struct _glapi_table *disp)
 {
    SET_GenQueriesARB(disp, _mesa_GenQueriesARB);
    SET_DeleteQueriesARB(disp, _mesa_DeleteQueriesARB);
@@ -716,16 +740,19 @@ _mesa_init_queryobj_dispatch(struct _glapi_table *disp)
    SET_BeginQueryARB(disp, _mesa_BeginQueryARB);
    SET_EndQueryARB(disp, _mesa_EndQueryARB);
    SET_GetQueryivARB(disp, _mesa_GetQueryivARB);
-   SET_GetQueryObjectivARB(disp, _mesa_GetQueryObjectivARB);
    SET_GetQueryObjectuivARB(disp, _mesa_GetQueryObjectuivARB);
-   SET_QueryCounter(disp, _mesa_QueryCounter);
 
-   SET_GetQueryObjecti64vEXT(disp, _mesa_GetQueryObjecti64vEXT);
-   SET_GetQueryObjectui64vEXT(disp, _mesa_GetQueryObjectui64vEXT);
+   if (_mesa_is_desktop_gl(ctx)) {
+      SET_GetQueryObjectivARB(disp, _mesa_GetQueryObjectivARB);
+      SET_QueryCounter(disp, _mesa_QueryCounter);
+
+      SET_GetQueryObjecti64vEXT(disp, _mesa_GetQueryObjecti64vEXT);
+      SET_GetQueryObjectui64vEXT(disp, _mesa_GetQueryObjectui64vEXT);
 
-   SET_BeginQueryIndexed(disp, _mesa_BeginQueryIndexed);
-   SET_EndQueryIndexed(disp, _mesa_EndQueryIndexed);
-   SET_GetQueryIndexediv(disp, _mesa_GetQueryIndexediv);
+      SET_BeginQueryIndexed(disp, _mesa_BeginQueryIndexed);
+      SET_EndQueryIndexed(disp, _mesa_EndQueryIndexed);
+      SET_GetQueryIndexediv(disp, _mesa_GetQueryIndexediv);
+   }
 }
 
 
diff --git a/mesalib/src/mesa/main/queryobj.h b/mesalib/src/mesa/main/queryobj.h
index 0f662fb57..1e35185c7 100644
--- a/mesalib/src/mesa/main/queryobj.h
+++ b/mesalib/src/mesa/main/queryobj.h
@@ -44,7 +44,8 @@ extern void
 _mesa_init_query_object_functions(struct dd_function_table *driver);
 
 extern void
-_mesa_init_queryobj_dispatch(struct _glapi_table *disp);
+_mesa_init_queryobj_dispatch(const struct gl_context *ctx,
+                             struct _glapi_table *disp);
 
 extern void
 _mesa_init_queryobj(struct gl_context *ctx);
diff --git a/mesalib/src/mesa/main/samplerobj.c b/mesalib/src/mesa/main/samplerobj.c
index 4514b1224..09cbd2939 100644
--- a/mesalib/src/mesa/main/samplerobj.c
+++ b/mesalib/src/mesa/main/samplerobj.c
@@ -1444,7 +1444,8 @@ _mesa_init_sampler_object_functions(struct dd_function_table *driver)
 
 
 void
-_mesa_init_sampler_object_dispatch(struct _glapi_table *disp)
+_mesa_init_sampler_object_dispatch(const struct gl_context *ctx,
+                                   struct _glapi_table *disp)
 {
    SET_GenSamplers(disp, _mesa_GenSamplers);
    SET_DeleteSamplers(disp, _mesa_DeleteSamplers);
@@ -1454,10 +1455,13 @@ _mesa_init_sampler_object_dispatch(struct _glapi_table *disp)
    SET_SamplerParameterf(disp, _mesa_SamplerParameterf);
    SET_SamplerParameteriv(disp, _mesa_SamplerParameteriv);
    SET_SamplerParameterfv(disp, _mesa_SamplerParameterfv);
-   SET_SamplerParameterIiv(disp, _mesa_SamplerParameterIiv);
-   SET_SamplerParameterIuiv(disp, _mesa_SamplerParameterIuiv);
    SET_GetSamplerParameteriv(disp, _mesa_GetSamplerParameteriv);
    SET_GetSamplerParameterfv(disp, _mesa_GetSamplerParameterfv);
-   SET_GetSamplerParameterIiv(disp, _mesa_GetSamplerParameterIiv);
-   SET_GetSamplerParameterIuiv(disp, _mesa_GetSamplerParameterIuiv);
+
+   if (_mesa_is_desktop_gl(ctx)) {
+      SET_SamplerParameterIiv(disp, _mesa_SamplerParameterIiv);
+      SET_SamplerParameterIuiv(disp, _mesa_SamplerParameterIuiv);
+      SET_GetSamplerParameterIiv(disp, _mesa_GetSamplerParameterIiv);
+      SET_GetSamplerParameterIuiv(disp, _mesa_GetSamplerParameterIuiv);
+   }
 }
diff --git a/mesalib/src/mesa/main/samplerobj.h b/mesalib/src/mesa/main/samplerobj.h
index e70ee4881..bea4c2232 100644
--- a/mesalib/src/mesa/main/samplerobj.h
+++ b/mesalib/src/mesa/main/samplerobj.h
@@ -77,7 +77,8 @@ extern void
 _mesa_init_sampler_object_functions(struct dd_function_table *driver);
 
 extern void
-_mesa_init_sampler_object_dispatch(struct _glapi_table *disp);
+_mesa_init_sampler_object_dispatch(const struct gl_context *ctx,
+                                   struct _glapi_table *disp);
 
 extern void GLAPIENTRY
 _mesa_BindSampler(GLuint unit, GLuint sampler);
diff --git a/mesalib/src/mesa/main/transformfeedback.c b/mesalib/src/mesa/main/transformfeedback.c
index ea6cfdf8c..0669b3a25 100644
--- a/mesalib/src/mesa/main/transformfeedback.c
+++ b/mesalib/src/mesa/main/transformfeedback.c
@@ -246,12 +246,15 @@ _mesa_init_transform_feedback_functions(struct dd_function_table *driver)
 
 
 void
-_mesa_init_transform_feedback_dispatch(struct _glapi_table *disp)
+_mesa_init_transform_feedback_dispatch(const struct gl_context *ctx,
+                                       struct _glapi_table *disp)
 {
    /* EXT_transform_feedback */
    SET_BeginTransformFeedbackEXT(disp, _mesa_BeginTransformFeedback);
    SET_EndTransformFeedbackEXT(disp, _mesa_EndTransformFeedback);
-   SET_BindBufferOffsetEXT(disp, _mesa_BindBufferOffsetEXT);
+   if (_mesa_is_desktop_gl(ctx)) {
+      SET_BindBufferOffsetEXT(disp, _mesa_BindBufferOffsetEXT);
+   }
    SET_TransformFeedbackVaryingsEXT(disp, _mesa_TransformFeedbackVaryings);
    SET_GetTransformFeedbackVaryingEXT(disp, _mesa_GetTransformFeedbackVarying);
    /* ARB_transform_feedback2 */
diff --git a/mesalib/src/mesa/main/transformfeedback.h b/mesalib/src/mesa/main/transformfeedback.h
index 7d4a945c5..6ff9c50b4 100644
--- a/mesalib/src/mesa/main/transformfeedback.h
+++ b/mesalib/src/mesa/main/transformfeedback.h
@@ -47,7 +47,8 @@ extern void
 _mesa_init_transform_feedback_functions(struct dd_function_table *driver);
 
 extern void
-_mesa_init_transform_feedback_dispatch(struct _glapi_table *disp);
+_mesa_init_transform_feedback_dispatch(const struct gl_context *ctx,
+                                       struct _glapi_table *disp);
 
 
 /*** GL_EXT_transform_feedback ***/
diff --git a/mesalib/src/mesa/main/uniforms.c b/mesalib/src/mesa/main/uniforms.c
index 39fac1534..d89255aaa 100644
--- a/mesalib/src/mesa/main/uniforms.c
+++ b/mesalib/src/mesa/main/uniforms.c
@@ -853,20 +853,24 @@ _mesa_init_shader_uniform_dispatch(const struct gl_context *ctx,
       SET_Uniform4uivEXT(exec, _mesa_Uniform4uiv);
       SET_GetUniformuivEXT(exec, _mesa_GetUniformuiv);
 
-      /* GL_ARB_robustness */
-      SET_GetnUniformfvARB(exec, _mesa_GetnUniformfvARB);
-      SET_GetnUniformivARB(exec, _mesa_GetnUniformivARB);
-      SET_GetnUniformuivARB(exec, _mesa_GetnUniformuivARB);
-      SET_GetnUniformdvARB(exec, _mesa_GetnUniformdvARB); /* GL 4.0 */
-
       /* GL_ARB_uniform_buffer_object / GL 3.1 */
       SET_GetUniformBlockIndex(exec, _mesa_GetUniformBlockIndex);
       SET_GetUniformIndices(exec, _mesa_GetUniformIndices);
       SET_GetActiveUniformsiv(exec, _mesa_GetActiveUniformsiv);
       SET_GetActiveUniformBlockiv(exec, _mesa_GetActiveUniformBlockiv);
       SET_GetActiveUniformBlockName(exec, _mesa_GetActiveUniformBlockName);
-      SET_GetActiveUniformName(exec, _mesa_GetActiveUniformName);
       SET_UniformBlockBinding(exec, _mesa_UniformBlockBinding);
    }
+
+   if (_mesa_is_desktop_gl(ctx)) {
+      /* GL_ARB_robustness */
+      SET_GetnUniformfvARB(exec, _mesa_GetnUniformfvARB);
+      SET_GetnUniformivARB(exec, _mesa_GetnUniformivARB);
+      SET_GetnUniformuivARB(exec, _mesa_GetnUniformuivARB);
+      SET_GetnUniformdvARB(exec, _mesa_GetnUniformdvARB);
+
+      /* GL_ARB_uniform_buffer_object / GL 3.1 */
+      SET_GetActiveUniformName(exec, _mesa_GetActiveUniformName);
+   }
 #endif /* FEATURE_GL */
 }
diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c
index b19dc67bf..6c287b3d4 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c
@@ -1120,7 +1120,10 @@ copy_image_data_to_texture(struct st_context *st,
 
       assert(src_level <= stImage->pt->last_level);
       assert(u_minify(stImage->pt->width0, src_level) == stImage->base.Width);
-      assert(u_minify(stImage->pt->height0, src_level) == stImage->base.Height);
+      assert(stImage->pt->target == PIPE_TEXTURE_1D_ARRAY ||
+             u_minify(stImage->pt->height0, src_level) == stImage->base.Height);
+      assert(stImage->pt->target == PIPE_TEXTURE_2D_ARRAY ||
+             u_minify(stImage->pt->depth0, src_level) == stImage->base.Depth);
 
       st_texture_image_copy(st->pipe,
                             stObj->pt, dstLevel,  /* dest texture, level */
diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 705f2b055..14b72dc80 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -630,6 +630,11 @@ glsl_to_tgsi_visitor::get_opcode(ir_instruction *ir, unsigned op,
 {
    int type = GLSL_TYPE_FLOAT;
    
+   assert(src0.type != GLSL_TYPE_ARRAY);
+   assert(src0.type != GLSL_TYPE_STRUCT);
+   assert(src1.type != GLSL_TYPE_ARRAY);
+   assert(src1.type != GLSL_TYPE_STRUCT);
+
    if (src0.type == GLSL_TYPE_FLOAT || src1.type == GLSL_TYPE_FLOAT)
       type = GLSL_TYPE_FLOAT;
    else if (native_integers)
@@ -1071,8 +1076,12 @@ glsl_to_tgsi_visitor::visit(ir_variable *ir)
                assert(index == storage->index + (int)i);
             }
          } else {
-            st_src_reg src(PROGRAM_STATE_VAR, index,
-                  native_integers ? ir->type->base_type : GLSL_TYPE_FLOAT);
+         	/* We use GLSL_TYPE_FLOAT here regardless of the actual type of
+         	 * the data being moved since MOV does not care about the type of
+         	 * data it is moving, and we don't want to declare registers with
+         	 * array or struct types.
+         	 */
+            st_src_reg src(PROGRAM_STATE_VAR, index, GLSL_TYPE_FLOAT);
             src.swizzle = slots[i].swizzle;
             emit(ir, TGSI_OPCODE_MOV, dst, src);
             /* even a float takes up a whole vec4 reg in a struct/array. */
@@ -2039,6 +2048,9 @@ glsl_to_tgsi_visitor::visit(ir_dereference_array *ir)
    else
       src.swizzle = SWIZZLE_NOOP;
 
+   /* Change the register type to the element type of the array. */
+   src.type = ir->type->base_type;
+
    this->result = src;
 }
 
@@ -2064,6 +2076,7 @@ glsl_to_tgsi_visitor::visit(ir_dereference_record *ir)
       this->result.swizzle = SWIZZLE_NOOP;
 
    this->result.index += offset;
+   this->result.type = ir->type->base_type;
 }
 
 /**
@@ -2283,6 +2296,10 @@ glsl_to_tgsi_visitor::visit(ir_assignment *ir)
       inst->dead_mask = inst->dst.writemask;
    } else {
       for (i = 0; i < type_size(ir->lhs->type); i++) {
+         if (ir->rhs->type->is_array())
+         	r.type = ir->rhs->type->element_type()->base_type;
+         else if (ir->rhs->type->is_record())
+         	r.type = ir->rhs->type->fields.structure[i].type->base_type;
          emit(ir, TGSI_OPCODE_MOV, l, r);
          l.index++;
          r.index++;
diff --git a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c
index a023058d0..0acab4340 100644
--- a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c
+++ b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c
@@ -118,11 +118,8 @@ static unsigned *get_label( struct st_translate *t,
    unsigned i;
 
    if (t->labels_count + 1 >= t->labels_size) {
-      unsigned old_size = t->labels_size;
       t->labels_size = 1 << (util_logbase2(t->labels_size) + 1);
-      t->labels = REALLOC( t->labels, 
-                           old_size * sizeof t->labels[0], 
-                           t->labels_size * sizeof t->labels[0] );
+      t->labels = realloc(t->labels, t->labels_size * sizeof t->labels[0]);
       if (t->labels == NULL) {
          static unsigned dummy;
          t->error = TRUE;
@@ -146,11 +143,8 @@ static void set_insn_start( struct st_translate *t,
                             unsigned start )
 {
    if (t->insn_count + 1 >= t->insn_size) {
-      unsigned old_size = t->insn_size;
       t->insn_size = 1 << (util_logbase2(t->insn_size) + 1);
-      t->insn = REALLOC( t->insn, 
-                         old_size * sizeof t->insn[0], 
-                         t->insn_size * sizeof t->insn[0] );
+      t->insn = realloc(t->insn, t->insn_size * sizeof t->insn[0]);
       if (t->insn == NULL) {
          t->error = TRUE;
          return;
@@ -1265,5 +1259,5 @@ out:
 void
 st_free_tokens(const struct tgsi_token *tokens)
 {
-   free((void *)tokens);
+   ureg_free_tokens(tokens);
 }
-- 
cgit v1.2.3