From 41fea4472dec859ddec76bdfa7108ebec71de1e3 Mon Sep 17 00:00:00 2001
From: marha <marha@users.sourceforge.net>
Date: Fri, 21 Mar 2014 19:36:05 +0100
Subject: xserver fontconfig libX11 libXext libxcb mesa git update 21 Mar 2014

xserver          commit 4fb31e4824d46edc80bb49b4065152899faa5ac6
libxcb           commit cb686b576739deea00180c54697c8b62b8419ae0
libX11           commit 8be4610939b833587954957f5963eb4191b43d19
libXext          commit 11aad96bd689d54156064d2e81213dc827a689d1
fontconfig       commit 5478192f379d784b421329e4bf72cc780818e467
mesa             commit 8d8d0cb09eb8735a04fc36cc4d0e2dc9f9d460eb
---
 mesalib/src/mesa/main/blend.c                      |  4 +-
 mesalib/src/mesa/main/buffers.c                    |  7 +-
 mesalib/src/mesa/main/context.c                    | 82 ++++++++++++++++------
 mesalib/src/mesa/main/errors.c                     |  5 +-
 mesalib/src/mesa/main/fbobject.c                   |  4 --
 mesalib/src/mesa/main/genmipmap.c                  |  4 ++
 mesalib/src/mesa/main/get.c                        |  6 +-
 mesalib/src/mesa/main/mipmap.c                     | 44 ++++++------
 mesalib/src/mesa/main/mtypes.h                     |  6 ++
 mesalib/src/mesa/main/teximage.c                   | 16 ++---
 mesalib/src/mesa/program/register_allocate.c       | 76 ++++++++++++--------
 mesalib/src/mesa/program/register_allocate.h       |  8 ++-
 mesalib/src/mesa/state_tracker/st_atom.c           | 22 ++++--
 .../src/mesa/state_tracker/st_atom_rasterizer.c    |  8 +++
 mesalib/src/mesa/state_tracker/st_atom_shader.c    |  9 +--
 mesalib/src/mesa/state_tracker/st_context.h        |  3 +-
 mesalib/src/mesa/state_tracker/st_draw.c           | 10 ---
 mesalib/src/mesa/state_tracker/st_gen_mipmap.c     |  3 +-
 mesalib/src/mesa/state_tracker/st_program.c        |  4 +-
 19 files changed, 200 insertions(+), 121 deletions(-)

(limited to 'mesalib/src/mesa')

diff --git a/mesalib/src/mesa/main/blend.c b/mesalib/src/mesa/main/blend.c
index eb4f1d6be..c37c0fea5 100644
--- a/mesalib/src/mesa/main/blend.c
+++ b/mesalib/src/mesa/main/blend.c
@@ -911,7 +911,9 @@ void _mesa_init_color( struct gl_context * ctx )
    ctx->Color.LogicOp = GL_COPY;
    ctx->Color.DitherFlag = GL_TRUE;
 
-   if (ctx->Visual.doubleBufferMode) {
+   /* GL_FRONT is not possible on GLES. Instead GL_BACK will render to either
+    * the front or the back buffer depending on the config */
+   if (ctx->Visual.doubleBufferMode || _mesa_is_gles(ctx)) {
       ctx->Color.DrawBuffer[0] = GL_BACK;
    }
    else {
diff --git a/mesalib/src/mesa/main/buffers.c b/mesalib/src/mesa/main/buffers.c
index 6cbce9d5d..b13a7af65 100644
--- a/mesalib/src/mesa/main/buffers.c
+++ b/mesalib/src/mesa/main/buffers.c
@@ -101,7 +101,7 @@ draw_buffer_enum_to_bitmask(const struct gl_context *ctx, GLenum buffer)
       case GL_FRONT:
          return BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_FRONT_RIGHT;
       case GL_BACK:
-         if (_mesa_is_gles3(ctx)) {
+         if (_mesa_is_gles(ctx)) {
             /* Page 181 (page 192 of the PDF) in section 4.2.1 of the OpenGL
              * ES 3.0.1 specification says:
              *
@@ -111,6 +111,11 @@ draw_buffer_enum_to_bitmask(const struct gl_context *ctx, GLenum buffer)
              *
              * Since there is no stereo rendering in ES 3.0, only return the
              * LEFT bits.  This also satisfies the "n must be 1" requirement.
+             *
+             * We also do this for GLES 1 and 2 because those APIs have no
+             * concept of selecting the front and back buffer anyway and it's
+             * convenient to be able to maintain the magic behaviour of
+             * GL_BACK in that case.
              */
             if (ctx->DrawBuffer->Visual.doubleBufferMode)
                return BUFFER_BIT_BACK_LEFT;
diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c
index 5b77ce103..cd009c115 100644
--- a/mesalib/src/mesa/main/context.c
+++ b/mesalib/src/mesa/main/context.c
@@ -1013,7 +1013,8 @@ _mesa_initialize_dispatch_tables(struct gl_context *ctx)
  *
  * \param ctx the context to initialize
  * \param api the GL API type to create the context for
- * \param visual describes the visual attributes for this context
+ * \param visual describes the visual attributes for this context or NULL to
+ *               create a configless context
  * \param share_list points to context to share textures, display lists,
  *        etc with, or NULL
  * \param driverFunctions table of device driver functions for this context
@@ -1033,12 +1034,20 @@ _mesa_initialize_context(struct gl_context *ctx,
    assert(driverFunctions->FreeTextureImageBuffer);
 
    ctx->API = api;
-   ctx->Visual = *visual;
    ctx->DrawBuffer = NULL;
    ctx->ReadBuffer = NULL;
    ctx->WinSysDrawBuffer = NULL;
    ctx->WinSysReadBuffer = NULL;
 
+   if (visual) {
+      ctx->Visual = *visual;
+      ctx->HasConfig = GL_TRUE;
+   }
+   else {
+      memset(&ctx->Visual, 0, sizeof ctx->Visual);
+      ctx->HasConfig = GL_FALSE;
+   }
+
    if (_mesa_is_desktop_gl(ctx)) {
       _mesa_override_gl_version(ctx);
    }
@@ -1145,7 +1154,8 @@ fail:
  * the rendering context.
  *
  * \param api the GL API type to create the context for
- * \param visual a struct gl_config pointer (we copy the struct contents)
+ * \param visual a struct gl_config pointer (we copy the struct contents) or
+ *               NULL to create a configless context
  * \param share_list another context to share display lists with or NULL
  * \param driverFunctions points to the dd_function_table into which the
  *        driver has plugged in all its special functions.
@@ -1160,8 +1170,6 @@ _mesa_create_context(gl_api api,
 {
    struct gl_context *ctx;
 
-   ASSERT(visual);
-
    ctx = calloc(1, sizeof(struct gl_context));
    if (!ctx)
       return NULL;
@@ -1475,6 +1483,54 @@ _mesa_check_init_viewport(struct gl_context *ctx, GLuint width, GLuint height)
    }
 }
 
+static void
+handle_first_current(struct gl_context *ctx)
+{
+   GLenum buffer;
+   GLint bufferIndex;
+
+   assert(ctx->Version > 0);
+
+   ctx->Extensions.String = _mesa_make_extension_string(ctx);
+
+   check_context_limits(ctx);
+
+   /* According to GL_MESA_configless_context the default value of
+    * glDrawBuffers depends on the config of the first surface it is bound to.
+    * For GLES it is always GL_BACK which has a magic interpretation */
+   if (!ctx->HasConfig && _mesa_is_desktop_gl(ctx)) {
+      if (ctx->DrawBuffer != _mesa_get_incomplete_framebuffer()) {
+         if (ctx->DrawBuffer->Visual.doubleBufferMode)
+            buffer = GL_BACK;
+         else
+            buffer = GL_FRONT;
+
+         _mesa_drawbuffers(ctx, 1, &buffer, NULL /* destMask */);
+      }
+
+      if (ctx->ReadBuffer != _mesa_get_incomplete_framebuffer()) {
+         if (ctx->ReadBuffer->Visual.doubleBufferMode) {
+            buffer = GL_BACK;
+            bufferIndex = BUFFER_BACK_LEFT;
+         }
+         else {
+            buffer = GL_FRONT;
+            bufferIndex = BUFFER_FRONT_LEFT;
+         }
+
+         _mesa_readbuffer(ctx, buffer, bufferIndex);
+      }
+   }
+
+   /* We can use this to help debug user's problems.  Tell them to set
+    * the MESA_INFO env variable before running their app.  Then the
+    * first time each context is made current we'll print some useful
+    * information.
+    */
+   if (_mesa_getenv("MESA_INFO")) {
+      _mesa_print_info(ctx);
+   }
+}
 
 /**
  * Bind the given context to the given drawBuffer and readBuffer and
@@ -1567,21 +1623,7 @@ _mesa_make_current( struct gl_context *newCtx,
       }
 
       if (newCtx->FirstTimeCurrent) {
-         assert(newCtx->Version > 0);
-
-         newCtx->Extensions.String = _mesa_make_extension_string(newCtx);
-
-         check_context_limits(newCtx);
-
-         /* We can use this to help debug user's problems.  Tell them to set
-          * the MESA_INFO env variable before running their app.  Then the
-          * first time each context is made current we'll print some useful
-          * information.
-          */
-	 if (_mesa_getenv("MESA_INFO")) {
-	    _mesa_print_info(newCtx);
-	 }
-
+         handle_first_current(newCtx);
 	 newCtx->FirstTimeCurrent = GL_FALSE;
       }
    }
diff --git a/mesalib/src/mesa/main/errors.c b/mesalib/src/mesa/main/errors.c
index 8ec6a8c33..9151718ea 100644
--- a/mesalib/src/mesa/main/errors.c
+++ b/mesalib/src/mesa/main/errors.c
@@ -969,7 +969,7 @@ _mesa_init_errors(struct gl_context *ctx)
 
 /**
  * Loop through debug group stack tearing down states for
- * filtering debug messages.
+ * filtering debug messages.  Then free debug output state.
  */
 void
 _mesa_free_errors_data(struct gl_context *ctx)
@@ -980,6 +980,9 @@ _mesa_free_errors_data(struct gl_context *ctx)
       for (i = 0; i <= ctx->Debug->GroupStackDepth; i++) {
          free_errors_data(ctx, i);
       }
+      FREE(ctx->Debug);
+      /* set to NULL just in case it is used before context is completely gone. */
+      ctx->Debug = NULL;
    }
 }
 
diff --git a/mesalib/src/mesa/main/fbobject.c b/mesalib/src/mesa/main/fbobject.c
index a9dcc5144..dfe2f1e93 100644
--- a/mesalib/src/mesa/main/fbobject.c
+++ b/mesalib/src/mesa/main/fbobject.c
@@ -1565,10 +1565,6 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat)
       return ctx->API == API_OPENGL_COMPAT &&
              ctx->Extensions.ARB_texture_float &&
              ctx->Extensions.ARB_framebuffer_object ? GL_INTENSITY : 0;
-   case GL_RGB9_E5:
-      return (_mesa_is_desktop_gl(ctx)
-              && ctx->Extensions.EXT_texture_shared_exponent)
-         ? GL_RGB : 0;
    case GL_R11F_G11F_B10F:
       return ((_mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_packed_float) ||
               _mesa_is_gles3(ctx) /* EXT_color_buffer_float */ )
diff --git a/mesalib/src/mesa/main/genmipmap.c b/mesalib/src/mesa/main/genmipmap.c
index dcd482da2..9d111cab2 100644
--- a/mesalib/src/mesa/main/genmipmap.c
+++ b/mesalib/src/mesa/main/genmipmap.c
@@ -74,6 +74,10 @@ _mesa_GenerateMipmap(GLenum target)
       error = (_mesa_is_gles(ctx) && ctx->Version < 30)
          || !ctx->Extensions.EXT_texture_array;
       break;
+   case GL_TEXTURE_CUBE_MAP_ARRAY:
+      error = _mesa_is_gles(ctx) ||
+              !ctx->Extensions.ARB_texture_cube_map_array;
+      break;
    default:
       error = GL_TRUE;
    }
diff --git a/mesalib/src/mesa/main/get.c b/mesalib/src/mesa/main/get.c
index b1908515c..88cf202df 100644
--- a/mesalib/src/mesa/main/get.c
+++ b/mesalib/src/mesa/main/get.c
@@ -1997,7 +1997,7 @@ _mesa_GetBooleani_v( GLenum pname, GLuint index, GLboolean *params )
       params[3] = INT_TO_BOOLEAN(v.value_int_4[3]);
       break;
    case TYPE_INT64:
-      params[0] = INT64_TO_BOOLEAN(v.value_int);
+      params[0] = INT64_TO_BOOLEAN(v.value_int64);
       break;
    default:
       ; /* nothing - GL error was recorded */
@@ -2042,7 +2042,7 @@ _mesa_GetIntegeri_v( GLenum pname, GLuint index, GLint *params )
       params[3] = v.value_int_4[3];
       break;
    case TYPE_INT64:
-      params[0] = INT64_TO_INT(v.value_int);
+      params[0] = INT64_TO_INT(v.value_int64);
       break;
    default:
       ; /* nothing - GL error was recorded */
@@ -2067,7 +2067,7 @@ _mesa_GetInteger64i_v( GLenum pname, GLuint index, GLint64 *params )
       params[3] = v.value_int_4[3];
       break;
    case TYPE_INT64:
-      params[0] = v.value_int;
+      params[0] = v.value_int64;
       break;
    default:
       ; /* nothing - GL error was recorded */
diff --git a/mesalib/src/mesa/main/mipmap.c b/mesalib/src/mesa/main/mipmap.c
index 521b2d8eb..cc109cc52 100644
--- a/mesalib/src/mesa/main/mipmap.c
+++ b/mesalib/src/mesa/main/mipmap.c
@@ -1548,23 +1548,18 @@ make_3d_mipmap(GLenum datatype, GLuint comps, GLint border,
    const GLint dstDepthNB = dstDepth - 2 * border;
    GLint img, row;
    GLint bytesPerSrcImage, bytesPerDstImage;
-   GLint bytesPerSrcRow, bytesPerDstRow;
    GLint srcImageOffset, srcRowOffset;
 
    (void) srcDepthNB; /* silence warnings */
 
-
-   bytesPerSrcImage = srcWidth * srcHeight * bpt;
-   bytesPerDstImage = dstWidth * dstHeight * bpt;
-
-   bytesPerSrcRow = srcWidth * bpt;
-   bytesPerDstRow = dstWidth * bpt;
+   bytesPerSrcImage = srcRowStride * srcHeight * bpt;
+   bytesPerDstImage = dstRowStride * dstHeight * bpt;
 
    /* Offset between adjacent src images to be averaged together */
    srcImageOffset = (srcDepth == dstDepth) ? 0 : 1;
 
    /* Offset between adjacent src rows to be averaged together */
-   srcRowOffset = (srcHeight == dstHeight) ? 0 : srcWidth * bpt;
+   srcRowOffset = (srcHeight == dstHeight) ? 0 : srcRowStride;
 
    /*
     * Need to average together up to 8 src pixels for each dest pixel.
@@ -1582,14 +1577,14 @@ make_3d_mipmap(GLenum datatype, GLuint comps, GLint border,
    for (img = 0; img < dstDepthNB; img++) {
       /* first source image pointer, skipping border */
       const GLubyte *imgSrcA = srcPtr[img * 2 + border]
-         + bytesPerSrcRow * border + bpt * border;
+         + srcRowStride * border + bpt * border;
       /* second source image pointer, skipping border */
       const GLubyte *imgSrcB = srcPtr[img * 2 + srcImageOffset + border]
-         + bytesPerSrcRow * border + bpt * border;
+         + srcRowStride * border + bpt * border;
 
       /* address of the dest image, skipping border */
       GLubyte *imgDst = dstPtr[img + border]
-         + bytesPerDstRow * border + bpt * border;
+         + dstRowStride * border + bpt * border;
 
       /* setup the four source row pointers and the dest row pointer */
       const GLubyte *srcImgARowA = imgSrcA;
@@ -1605,11 +1600,11 @@ make_3d_mipmap(GLenum datatype, GLuint comps, GLint border,
                    dstWidthNB, dstImgRow);
 
          /* advance to next rows */
-         srcImgARowA += bytesPerSrcRow + srcRowOffset;
-         srcImgARowB += bytesPerSrcRow + srcRowOffset;
-         srcImgBRowA += bytesPerSrcRow + srcRowOffset;
-         srcImgBRowB += bytesPerSrcRow + srcRowOffset;
-         dstImgRow += bytesPerDstRow;
+         srcImgARowA += srcRowStride + srcRowOffset;
+         srcImgARowB += srcRowStride + srcRowOffset;
+         srcImgBRowA += srcRowStride + srcRowOffset;
+         srcImgBRowB += srcRowStride + srcRowOffset;
+         dstImgRow += dstRowStride;
       }
    }
 
@@ -1638,8 +1633,8 @@ make_3d_mipmap(GLenum datatype, GLuint comps, GLint border,
             memcpy(dst, src, bpt);
 
             /* do border along [img][row=dstHeight-1][col=0] */
-            src = srcPtr[img * 2] + (srcHeight - 1) * bytesPerSrcRow;
-            dst = dstPtr[img] + (dstHeight - 1) * bytesPerDstRow;
+            src = srcPtr[img * 2] + (srcHeight - 1) * srcRowStride;
+            dst = dstPtr[img] + (dstHeight - 1) * dstRowStride;
             memcpy(dst, src, bpt);
 
             /* do border along [img][row=0][col=dstWidth-1] */
@@ -1668,10 +1663,10 @@ make_3d_mipmap(GLenum datatype, GLuint comps, GLint border,
 
             /* do border along [img][row=dstHeight-1][col=0] */
             srcA = srcPtr[img * 2 + 0]
-               + (srcHeight - 1) * bytesPerSrcRow;
+               + (srcHeight - 1) * srcRowStride;
             srcB = srcPtr[img * 2 + srcImageOffset]
-               + (srcHeight - 1) * bytesPerSrcRow;
-            dst = dstPtr[img] + (dstHeight - 1) * bytesPerDstRow;
+               + (srcHeight - 1) * srcRowStride;
+            dst = dstPtr[img] + (dstHeight - 1) * dstRowStride;
             do_row(datatype, comps, 1, srcA, srcB, 1, dst);
 
             /* do border along [img][row=0][col=dstWidth-1] */
@@ -1746,6 +1741,7 @@ _mesa_generate_mipmap_level(GLenum target,
       }
       break;
    case GL_TEXTURE_2D_ARRAY_EXT:
+   case GL_TEXTURE_CUBE_MAP_ARRAY:
       for (i = 0; i < dstDepth; i++) {
 	 make_2d_mipmap(datatype, comps, border,
 			srcWidth, srcHeight, srcData[i], srcRowStride,
@@ -1788,7 +1784,8 @@ _mesa_next_mipmap_level_size(GLenum target, GLint border,
    }
 
    if ((srcDepth - 2 * border > 1) &&
-       (target != GL_TEXTURE_2D_ARRAY_EXT)) {
+       (target != GL_TEXTURE_2D_ARRAY_EXT &&
+        target != GL_TEXTURE_CUBE_MAP_ARRAY)) {
       *dstDepth = (srcDepth - 2 * border) / 2 + 2 * border;
    }
    else {
@@ -2029,7 +2026,8 @@ generate_mipmap_compressed(struct gl_context *ctx, GLenum target,
    /* only two types of compressed textures at this time */
    assert(texObj->Target == GL_TEXTURE_2D ||
 	  texObj->Target == GL_TEXTURE_2D_ARRAY ||
-	  texObj->Target == GL_TEXTURE_CUBE_MAP_ARB);
+	  texObj->Target == GL_TEXTURE_CUBE_MAP_ARB ||
+          texObj->Target == GL_TEXTURE_CUBE_MAP_ARRAY);
 
    /*
     * Choose a format for the temporary, uncompressed base image.
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h
index 7c83d664f..c6d90c579 100644
--- a/mesalib/src/mesa/main/mtypes.h
+++ b/mesalib/src/mesa/main/mtypes.h
@@ -4212,6 +4212,12 @@ struct gl_context
    GLboolean FirstTimeCurrent;
    /*@}*/
 
+   /**
+    * False if this context was created without a config. This is needed
+    * because the initial state of glDrawBuffers depends on this
+    */
+   GLboolean HasConfig;
+
    /** software compression/decompression supported or not */
    GLboolean Mesa_DXTn;
 
diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c
index a6c3581bf..57a766f99 100644
--- a/mesalib/src/mesa/main/teximage.c
+++ b/mesalib/src/mesa/main/teximage.c
@@ -160,6 +160,9 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat )
          case GL_DEPTH_COMPONENT24:
          case GL_DEPTH_COMPONENT32:
             return GL_DEPTH_COMPONENT;
+         case GL_DEPTH_STENCIL:
+         case GL_DEPTH24_STENCIL8:
+            return GL_DEPTH_STENCIL;
          default:
             ; /* fallthrough */
       }
@@ -301,14 +304,6 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat )
       }
    }
 
-   switch (internalFormat) {
-   case GL_DEPTH_STENCIL:
-   case GL_DEPTH24_STENCIL8:
-      return GL_DEPTH_STENCIL;
-   default:
-      ; /* fallthrough */
-   }
-
    if (ctx->Extensions.EXT_texture_sRGB) {
       switch (internalFormat) {
       case GL_SRGB_EXT:
@@ -1662,7 +1657,10 @@ error_check_subtexture_dimensions(struct gl_context *ctx,
 
    /* check zoffset and depth */
    if (dims > 2) {
-      GLint zBorder = (target == GL_TEXTURE_2D_ARRAY) ? 0 : destImage->Border;
+      GLint zBorder = (target == GL_TEXTURE_2D_ARRAY ||
+                       target == GL_TEXTURE_CUBE_MAP_ARRAY) ?
+                         0 : destImage->Border;
+
       if (zoffset < -zBorder) {
          _mesa_error(ctx, GL_INVALID_VALUE, "%s3D(zoffset)", function);
          return GL_TRUE;
diff --git a/mesalib/src/mesa/program/register_allocate.c b/mesalib/src/mesa/program/register_allocate.c
index 4eed0b5aa..6fac69033 100644
--- a/mesalib/src/mesa/program/register_allocate.c
+++ b/mesalib/src/mesa/program/register_allocate.c
@@ -82,7 +82,7 @@
 #define NO_REG ~0
 
 struct ra_reg {
-   GLboolean *conflicts;
+   BITSET_WORD *conflicts;
    unsigned int *conflict_list;
    unsigned int conflict_list_size;
    unsigned int num_conflicts;
@@ -99,7 +99,12 @@ struct ra_regs {
 };
 
 struct ra_class {
-   GLboolean *regs;
+   /**
+    * Bitset indicating which registers belong to this class.
+    *
+    * (If bit N is set, then register N belongs to this class.)
+    */
+   BITSET_WORD *regs;
 
    /**
     * p(B) in Runeson/Nyström paper.
@@ -139,7 +144,7 @@ struct ra_node {
     * "remove the edge from the graph" in simplification without
     * having to actually modify the adjacency_list.
     */
-   GLboolean in_stack;
+   bool in_stack;
 
    /* For an implementation that needs register spilling, this is the
     * approximate cost of spilling this node.
@@ -186,8 +191,9 @@ ra_alloc_reg_set(void *mem_ctx, unsigned int count)
    regs->regs = rzalloc_array(regs, struct ra_reg, count);
 
    for (i = 0; i < count; i++) {
-      regs->regs[i].conflicts = rzalloc_array(regs->regs, GLboolean, count);
-      regs->regs[i].conflicts[i] = GL_TRUE;
+      regs->regs[i].conflicts = rzalloc_array(regs->regs, BITSET_WORD,
+                                              BITSET_WORDS(count));
+      BITSET_SET(regs->regs[i].conflicts, i);
 
       regs->regs[i].conflict_list = ralloc_array(regs->regs, unsigned int, 4);
       regs->regs[i].conflict_list_size = 4;
@@ -225,13 +231,13 @@ ra_add_conflict_list(struct ra_regs *regs, unsigned int r1, unsigned int r2)
 				     unsigned int, reg1->conflict_list_size);
    }
    reg1->conflict_list[reg1->num_conflicts++] = r2;
-   reg1->conflicts[r2] = GL_TRUE;
+   BITSET_SET(reg1->conflicts, r2);
 }
 
 void
 ra_add_reg_conflict(struct ra_regs *regs, unsigned int r1, unsigned int r2)
 {
-   if (!regs->regs[r1].conflicts[r2]) {
+   if (!BITSET_TEST(regs->regs[r1].conflicts, r2)) {
       ra_add_conflict_list(regs, r1, r2);
       ra_add_conflict_list(regs, r2, r1);
    }
@@ -269,7 +275,7 @@ ra_alloc_reg_class(struct ra_regs *regs)
    class = rzalloc(regs, struct ra_class);
    regs->classes[regs->class_count] = class;
 
-   class->regs = rzalloc_array(class, GLboolean, regs->count);
+   class->regs = rzalloc_array(class, BITSET_WORD, BITSET_WORDS(regs->count));
 
    return regs->class_count++;
 }
@@ -279,10 +285,19 @@ ra_class_add_reg(struct ra_regs *regs, unsigned int c, unsigned int r)
 {
    struct ra_class *class = regs->classes[c];
 
-   class->regs[r] = GL_TRUE;
+   BITSET_SET(class->regs, r);
    class->p++;
 }
 
+/**
+ * Returns true if the register belongs to the given class.
+ */
+static bool
+reg_belongs_to_class(unsigned int r, struct ra_class *c)
+{
+   return BITSET_TEST(c->regs, r);
+}
+
 /**
  * Must be called after all conflicts and register classes have been
  * set up and before the register set is used for allocation.
@@ -319,12 +334,12 @@ ra_set_finalize(struct ra_regs *regs, unsigned int **q_values)
 	    int conflicts = 0;
 	    int i;
 
-	    if (!regs->classes[c]->regs[rc])
+            if (!reg_belongs_to_class(rc, regs->classes[c]))
 	       continue;
 
 	    for (i = 0; i < regs->regs[rc].num_conflicts; i++) {
 	       unsigned int rb = regs->regs[rc].conflict_list[i];
-	       if (regs->classes[b]->regs[rb])
+	       if (BITSET_TEST(regs->classes[b]->regs, rb))
 		  conflicts++;
 	    }
 	    max_conflicts = MAX2(max_conflicts, conflicts);
@@ -397,7 +412,8 @@ ra_add_node_interference(struct ra_graph *g,
    }
 }
 
-static GLboolean pq_test(struct ra_graph *g, unsigned int n)
+static bool
+pq_test(struct ra_graph *g, unsigned int n)
 {
    unsigned int j;
    unsigned int q = 0;
@@ -420,18 +436,18 @@ static GLboolean pq_test(struct ra_graph *g, unsigned int n)
  * trivially-colorable nodes into a stack of nodes to be colored,
  * removing them from the graph, and rinsing and repeating.
  *
- * Returns GL_TRUE if all nodes were removed from the graph.  GL_FALSE
+ * Returns true if all nodes were removed from the graph.  false
  * means that either spilling will be required, or optimistic coloring
  * should be applied.
  */
-GLboolean
+bool
 ra_simplify(struct ra_graph *g)
 {
-   GLboolean progress = GL_TRUE;
+   bool progress = true;
    int i;
 
    while (progress) {
-      progress = GL_FALSE;
+      progress = false;
 
       for (i = g->count - 1; i >= 0; i--) {
 	 if (g->nodes[i].in_stack || g->nodes[i].reg != NO_REG)
@@ -440,18 +456,18 @@ ra_simplify(struct ra_graph *g)
 	 if (pq_test(g, i)) {
 	    g->stack[g->stack_count] = i;
 	    g->stack_count++;
-	    g->nodes[i].in_stack = GL_TRUE;
-	    progress = GL_TRUE;
+	    g->nodes[i].in_stack = true;
+	    progress = true;
 	 }
       }
    }
 
    for (i = 0; i < g->count; i++) {
       if (!g->nodes[i].in_stack && g->nodes[i].reg == -1)
-	 return GL_FALSE;
+	 return false;
    }
 
-   return GL_TRUE;
+   return true;
 }
 
 /**
@@ -459,9 +475,9 @@ ra_simplify(struct ra_graph *g)
  * registers as they go.
  *
  * If all nodes were trivially colorable, then this must succeed.  If
- * not (optimistic coloring), then it may return GL_FALSE;
+ * not (optimistic coloring), then it may return false;
  */
-GLboolean
+bool
 ra_select(struct ra_graph *g)
 {
    int i;
@@ -478,7 +494,7 @@ ra_select(struct ra_graph *g)
        */
       for (ri = 0; ri < g->regs->count; ri++) {
          r = (start_search_reg + ri) % g->regs->count;
-	 if (!c->regs[r])
+         if (!reg_belongs_to_class(r, c))
 	    continue;
 
 	 /* Check if any of our neighbors conflict with this register choice. */
@@ -486,7 +502,7 @@ ra_select(struct ra_graph *g)
 	    unsigned int n2 = g->nodes[n].adjacency_list[i];
 
 	    if (!g->nodes[n2].in_stack &&
-		g->regs->regs[r].conflicts[g->nodes[n2].reg]) {
+		BITSET_TEST(g->regs->regs[r].conflicts, g->nodes[n2].reg)) {
 	       break;
 	    }
 	 }
@@ -494,17 +510,17 @@ ra_select(struct ra_graph *g)
 	    break;
       }
       if (ri == g->regs->count)
-	 return GL_FALSE;
+	 return false;
 
       g->nodes[n].reg = r;
-      g->nodes[n].in_stack = GL_FALSE;
+      g->nodes[n].in_stack = false;
       g->stack_count--;
 
       if (g->regs->round_robin)
          start_search_reg = r + 1;
    }
 
-   return GL_TRUE;
+   return true;
 }
 
 /**
@@ -526,11 +542,11 @@ ra_optimistic_color(struct ra_graph *g)
 
       g->stack[g->stack_count] = i;
       g->stack_count++;
-      g->nodes[i].in_stack = GL_TRUE;
+      g->nodes[i].in_stack = true;
    }
 }
 
-GLboolean
+bool
 ra_allocate_no_spills(struct ra_graph *g)
 {
    if (!ra_simplify(g)) {
@@ -562,7 +578,7 @@ void
 ra_set_node_reg(struct ra_graph *g, unsigned int n, unsigned int reg)
 {
    g->nodes[n].reg = reg;
-   g->nodes[n].in_stack = GL_FALSE;
+   g->nodes[n].in_stack = false;
 }
 
 static float
diff --git a/mesalib/src/mesa/program/register_allocate.h b/mesalib/src/mesa/program/register_allocate.h
index fa119e320..337dcf709 100644
--- a/mesalib/src/mesa/program/register_allocate.h
+++ b/mesalib/src/mesa/program/register_allocate.h
@@ -25,6 +25,8 @@
  *
  */
 
+#include <stdbool.h>
+
 struct ra_class;
 struct ra_regs;
 
@@ -64,10 +66,10 @@ void ra_add_node_interference(struct ra_graph *g,
 /** @} */
 
 /** @{ Graph-coloring register allocation */
-GLboolean ra_simplify(struct ra_graph *g);
+bool ra_simplify(struct ra_graph *g);
 void ra_optimistic_color(struct ra_graph *g);
-GLboolean ra_select(struct ra_graph *g);
-GLboolean ra_allocate_no_spills(struct ra_graph *g);
+bool ra_select(struct ra_graph *g);
+bool ra_allocate_no_spills(struct ra_graph *g);
 
 unsigned int ra_get_node_reg(struct ra_graph *g, unsigned int n);
 void ra_set_node_reg(struct ra_graph * g, unsigned int n, unsigned int reg);
diff --git a/mesalib/src/mesa/state_tracker/st_atom.c b/mesalib/src/mesa/state_tracker/st_atom.c
index 32ce1eaaa..99e9df26b 100644
--- a/mesalib/src/mesa/state_tracker/st_atom.c
+++ b/mesalib/src/mesa/state_tracker/st_atom.c
@@ -132,16 +132,26 @@ static void check_program_state( struct st_context *st )
 static void check_attrib_edgeflag(struct st_context *st)
 {
    const struct gl_client_array **arrays = st->ctx->Array._DrawArrays;
-   GLboolean vertDataEdgeFlags;
+   GLboolean vertdata_edgeflags, edgeflag_culls_prims, edgeflags_enabled;
 
    if (!arrays)
       return;
 
-   vertDataEdgeFlags = arrays[VERT_ATTRIB_EDGEFLAG]->BufferObj &&
-                       arrays[VERT_ATTRIB_EDGEFLAG]->BufferObj->Name;
-   if (vertDataEdgeFlags != st->vertdata_edgeflags) {
-      st->vertdata_edgeflags = vertDataEdgeFlags;
-      st->dirty.st |= ST_NEW_EDGEFLAGS_DATA;
+   edgeflags_enabled = st->ctx->Polygon.FrontMode != GL_FILL ||
+                       st->ctx->Polygon.BackMode != GL_FILL;
+
+   vertdata_edgeflags = edgeflags_enabled &&
+                        arrays[VERT_ATTRIB_EDGEFLAG]->StrideB != 0;
+   if (vertdata_edgeflags != st->vertdata_edgeflags) {
+      st->vertdata_edgeflags = vertdata_edgeflags;
+      st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
+   }
+
+   edgeflag_culls_prims = edgeflags_enabled && !vertdata_edgeflags &&
+                          !st->ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0];
+   if (edgeflag_culls_prims != st->edgeflag_culls_prims) {
+      st->edgeflag_culls_prims = edgeflag_culls_prims;
+      st->dirty.st |= ST_NEW_RASTERIZER;
    }
 }
 
diff --git a/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c b/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c
index a4f3ffee3..ee5e9e574 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c
@@ -236,6 +236,14 @@ static void update_raster_state( struct st_context *st )
    /* ST_NEW_RASTERIZER */
    raster->rasterizer_discard = ctx->RasterDiscard;
 
+   if (st->edgeflag_culls_prims) {
+      /* All edge flags are FALSE. Cull the affected faces. */
+      if (raster->fill_front != PIPE_POLYGON_MODE_FILL)
+         raster->cull_face |= PIPE_FACE_FRONT;
+      if (raster->fill_back != PIPE_POLYGON_MODE_FILL)
+         raster->cull_face |= PIPE_FACE_BACK;
+   }
+
    /* _NEW_TRANSFORM */
    raster->depth_clip = ctx->Transform.DepthClamp == GL_FALSE;
    raster->clip_plane_enable = ctx->Transform.ClipPlanesEnabled;
diff --git a/mesalib/src/mesa/state_tracker/st_atom_shader.c b/mesalib/src/mesa/state_tracker/st_atom_shader.c
index ba04c1fb7..67c615713 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_shader.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_shader.c
@@ -141,11 +141,8 @@ update_vp( struct st_context *st )
     * edgeflag semantics, and extend the vertex shader to pass through
     * the input to the output.  We'll need to use similar logic to set
     * up the extra vertex_element input for edgeflags.
-    * _NEW_POLYGON, ST_NEW_EDGEFLAGS_DATA
     */
-   key.passthrough_edgeflags = (st->vertdata_edgeflags && (
-                                st->ctx->Polygon.FrontMode != GL_FILL ||
-                                st->ctx->Polygon.BackMode != GL_FILL));
+   key.passthrough_edgeflags = st->vertdata_edgeflags;
 
    key.clamp_color = st->clamp_vert_color_in_shader &&
                      st->ctx->Light._ClampVertexColor;
@@ -164,8 +161,8 @@ update_vp( struct st_context *st )
 const struct st_tracked_state st_update_vp = {
    "st_update_vp",					/* name */
    {							/* dirty */
-      _NEW_POLYGON,					/* mesa */
-      ST_NEW_VERTEX_PROGRAM | ST_NEW_EDGEFLAGS_DATA	/* st */
+      0,                                                /* mesa */
+      ST_NEW_VERTEX_PROGRAM                             /* st */
    },
    update_vp						/* update */
 };
diff --git a/mesalib/src/mesa/state_tracker/st_context.h b/mesalib/src/mesa/state_tracker/st_context.h
index 9c699a015..0e00dd4fa 100644
--- a/mesalib/src/mesa/state_tracker/st_context.h
+++ b/mesalib/src/mesa/state_tracker/st_context.h
@@ -47,7 +47,7 @@ struct u_upload_mgr;
 #define ST_NEW_FRAGMENT_PROGRAM        (1 << 1)
 #define ST_NEW_VERTEX_PROGRAM          (1 << 2)
 #define ST_NEW_FRAMEBUFFER             (1 << 3)
-#define ST_NEW_EDGEFLAGS_DATA          (1 << 4)
+/* gap, re-use it */
 #define ST_NEW_GEOMETRY_PROGRAM        (1 << 5)
 #define ST_NEW_VERTEX_ARRAYS           (1 << 6)
 #define ST_NEW_RASTERIZER              (1 << 7)
@@ -131,6 +131,7 @@ struct st_context
 
    GLboolean missing_textures;
    GLboolean vertdata_edgeflags;
+   GLboolean edgeflag_culls_prims;
 
    /** Mapping from VARYING_SLOT_x to post-transformed vertex slot */
    const GLuint *vertex_result_to_slot;
diff --git a/mesalib/src/mesa/state_tracker/st_draw.c b/mesalib/src/mesa/state_tracker/st_draw.c
index 355c180f8..dba5870a0 100644
--- a/mesalib/src/mesa/state_tracker/st_draw.c
+++ b/mesalib/src/mesa/state_tracker/st_draw.c
@@ -164,16 +164,6 @@ translate_prim(const struct gl_context *ctx, unsigned prim)
    STATIC_ASSERT(GL_QUADS == PIPE_PRIM_QUADS);
    STATIC_ASSERT(GL_TRIANGLE_STRIP_ADJACENCY == PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY);
 
-   /* Avoid quadstrips if it's easy to do so:
-    * Note: it's important to do the correct trimming if we change the
-    * prim type!  We do that wherever this function is called.
-    */
-   if (prim == GL_QUAD_STRIP &&
-       ctx->Light.ShadeModel != GL_FLAT &&
-       ctx->Polygon.FrontMode == GL_FILL &&
-       ctx->Polygon.BackMode == GL_FILL)
-      prim = GL_TRIANGLE_STRIP;
-
    return prim;
 }
 
diff --git a/mesalib/src/mesa/state_tracker/st_gen_mipmap.c b/mesalib/src/mesa/state_tracker/st_gen_mipmap.c
index 04333f75e..b615575b5 100644
--- a/mesalib/src/mesa/state_tracker/st_gen_mipmap.c
+++ b/mesalib/src/mesa/state_tracker/st_gen_mipmap.c
@@ -221,7 +221,8 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target,
       else {
          dstHeight = u_minify(pt->height0, dstLevel);
       }
-      if (texObj->Target == GL_TEXTURE_2D_ARRAY) {
+      if (texObj->Target == GL_TEXTURE_2D_ARRAY ||
+          texObj->Target == GL_TEXTURE_CUBE_MAP_ARRAY) {
          dstDepth = pt->array_size;
       }
       else {
diff --git a/mesalib/src/mesa/state_tracker/st_program.c b/mesalib/src/mesa/state_tracker/st_program.c
index e9074ac97..692a57008 100644
--- a/mesalib/src/mesa/state_tracker/st_program.c
+++ b/mesalib/src/mesa/state_tracker/st_program.c
@@ -342,14 +342,14 @@ st_translate_vertex_program(struct st_context *st,
                                    stvp->glsl_to_tgsi,
                                    &stvp->Base.Base,
                                    /* inputs */
-                                   stvp->num_inputs,
+                                   vpv->num_inputs,
                                    stvp->input_to_index,
                                    NULL, /* input semantic name */
                                    NULL, /* input semantic index */
                                    NULL, /* interp mode */
                                    NULL, /* is centroid */
                                    /* outputs */
-                                   stvp->num_outputs,
+                                   num_outputs,
                                    stvp->result_to_output,
                                    stvp->output_semantic_name,
                                    stvp->output_semantic_index,
-- 
cgit v1.2.3