Only glUniform1i() can be used to set sampler uniforms.  Generate error otherwise.
diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index e2fedf7..1914adb 100644
--- a/src/mesa/shader/shader_api.c
+++ b/src/mesa/shader/shader_api.c
@@ -891,8 +891,22 @@
 
    FLUSH_VERTICES(ctx, _NEW_PROGRAM);
 
+   /*
+    * If we're setting a sampler, we must use glUniformi1()!
+    */
+   if (shProg->Uniforms->Parameters[location].Type == PROGRAM_SAMPLER) {
+      if (type != GL_INT || count != 1) {
+         _mesa_error(ctx, GL_INVALID_OPERATION,
+                     "glUniform(only glUniform1i can be used "
+                     "to set sampler uniforms)");
+         return;
+      }
+   }
+
    uniformVal = shProg->Uniforms->ParameterValues[location];
 
+   /* XXX obey 'count' parameter! */
+
    if (type == GL_INT ||
        type == GL_INT_VEC2 ||
        type == GL_INT_VEC3 ||